Skip to main content
All CollectionsCommunity
Can I delay loading Intercom on my site to reduce the JS load?
Can I delay loading Intercom on my site to reduce the JS load?
Beth-Ann Sher avatar
Written by Beth-Ann Sher
Updated over a year ago


This answer comes from the Intercom Community forum. 👌


Can I delay loading Intercom on my site to reduce the JS load? i.e. only load it after a page is fully loaded for a visitor?

You can modify the Intercom load function by splitting it out like this, and it runs inside a setTimeout function

   // Intercom
window.intercomSettings = {
app_id: "<YOUR WIDGET ID>"
};

var w = window;
var ic = w.Intercom;
if (typeof ic === "function") {
ic('reattach_activator');
ic('update', w.intercomSettings);
} else {
var d = document;
var i = function() {
i.c(arguments);
};
i.q = [];
i.c = function(args) {
i.q.push(args);
};
w.Intercom = i;
var l = function() {
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://widget.intercom.io/widget/<YOUR WIDGET ID>';
var x = d.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
};
l();
}

The difference is that the part that runs l() normally is onLoad and that gets stuffed up after the setTimeout.

You can also strip out the l() function entirely if you like (and just have the variables declared etc) and just run it, as it’ll be wrapped in a setTimeout function.

Read this and other questions here on Intercom Community.


💡Tip

Need more help? Get support from our Community Forum
Find answers and get help from Intercom Support and Community Experts


Did this answer your question?