Yarushi
Yarushi

Reputation: 59

Delay loading of chat integration for few seconds

there is an integration for Smartsupp chat that goes like this:

<!-- Smartsupp Live Chat script -->
<script type="text/javascript">
var _smartsupp = _smartsupp || {};
_smartsupp.key = '5eafc30579aa75bb8bcb1c567a44502fc51fcbad';
window.smartsupp||(function(d) {
  var s,c,o=smartsupp=function(){ o._.push(arguments)};o._=[];
  s=d.getElementsByTagName('script')[0];c=d.createElement('script');
  c.type='text/javascript';c.charset='utf-8';c.async=true;
  c.src='https://www.smartsuppchat.com/loader.js?';s.parentNode.insertBefore(c,s);
})(document);
</script>

And im trying to delay the loading for example 3-5 sec after page is loaded. If user is jumping from page to page, he wont contact with me anyway.

Any idea how to touch it and keep it working? I've tried setTimeout but it seems to broke the code and nothing happens at all.

Upvotes: 0

Views: 323

Answers (1)

Gavin
Gavin

Reputation: 124

var _smartsupp = _smartsupp || {};
_smartsupp.key = '5eafc30579aa75bb8bcb1c567a44502fc51fcbad';
setTimeout(() => window.smartsupp || (function(d) {
    var s, c, o = smartsupp = function() {
        o._.push(arguments)
    };
    o._ = [];
    s = d.getElementsByTagName('script')[0];
    c = d.createElement('script');
    c.type = 'text/javascript';
    c.charset = 'utf-8';
    c.async = true;
    c.src = 'https://www.smartsuppchat.com/loader.js?';
    s.parentNode.insertBefore(c, s);
})(document), 1000);

Try this out. It appears to be working for me.

Upvotes: 1

Related Questions