Load Livechatinc Code After Webpage Is Fully Loaded
Solution 1:
from what I see there, the code is served from their servers and loaded async, so it doesn't really slow down the website, I found this: https://www.livechatinc.com/kb/is-livechat-slowing-my-website/ - check it out, they explain it rather well.
Solution 2:
I have found a solution I have included, google tag manager on which I have included all additional javascript codes, and I do the following.
<script>
(function(){
setTimeout(function(){
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
newDate().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5M93GPC');
}, 5000);
})()
</script>
Solution 3:
I like to load livechatinc.js 3 seconds after page load.
This can be accomplished with a little JS. Add this right before the closing </body>
tag. Make sure to replace <YOUR_LICENSE_NUMBER>
with your actual license number.
window.__lc = window.__lc || {};
window.__lc.license = <YOUR_LICENSE_NUMBER>;
window.onload = function() {
setTimeout(function(){
// Live Chat
!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"https://":"http://")+"cdn.livechatinc.com/tracking.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}();
}, 3000);
};
You can adjust the 3000 ms if you want to load it sooner or later.
For those of you interested in using Google Tag Manager to defer loading, you can follow Live Chat Inc's instructions here:
Post a Comment for "Load Livechatinc Code After Webpage Is Fully Loaded"