Installing Appcues Asynchronously (Developer)
Learn how to install Appcues in your web app asynchronously.
This document includes sample code on how to install Appcues in your web app asynchronously. With this method the Appcues SDK can be loaded asynchronously, allowing it to load simultaneously with other scripts, which can lessen the impact on page load times.
<script>
(function() {
if (!window.AppcuesReady) {
window.AppcuesReady = function(callback) {
callback && window.AppcuesReady.q.push(callback);
if (window.Appcues) {
while (window.AppcuesReady.q.length) {
cb = window.AppcuesReady.q.shift();
if (typeof cb === 'function') cb();
}
}
};
window.AppcuesReady.q = [];
}
})()
</script>
<script>
// You could then call Appcues methods immediately
// by calling AppcuesReady() with a callback:
AppcuesReady(function() {
Appcues.identify('userId', {email: 'test@appcues.com'});
});
</script>
<!-- Load your Appcues script at any time later -->
<script src="//fast.appcues.com/23.js" async onload="AppcuesReady()"></script>