Skip to content

Instantly share code, notes, and snippets.

@hijonathan
Created September 30, 2015 02:24
Show Gist options
  • Save hijonathan/772c7d883acb0f27f0db to your computer and use it in GitHub Desktop.
Save hijonathan/772c7d883acb0f27f0db to your computer and use it in GitHub Desktop.
Load Appcues asynchronously in a wrapped method.
<script>
(function(a, ns, cb) {
window[ns] = function(callback) {
(window[ns].q = window[ns].q || []).push(callback);
if (window[a] != null) {
while (window[ns].q.length) {
cb = window[ns].q.shift();
if (typeof cb === 'function') cb();
}
}
};
})('Appcues', 'AppcuesReady');
</script>
<script>
// You could then use Appcues immediately by calling Appcues.ready() with a callback:
AppcuesReady(function() {
Appcues.identify('userId', {email: '[email protected]'});
});
</script>
<!-- Load the script at any time later -->
<script src="//fast.appcues.com/23.js" async defer onload="AppcuesReady()">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment