📜 ⬆️ ⬇️

We accelerate the site with JivoSite. Delayed download online consultant

When assessing the download speed of the site by Google , I noticed that we are losing quite a lot of points due to the installed JivoSite online consultant. When removing the code of the online consultant from the site, the project gains 16 points more for the mobile version and 19 points more for the PC version.

Therefore, the question arose about the delayed download online consultant. Moreover, deferred download should work for Google speed test and not interfere with the work of online consultants. For example, if the dialogue has already begun, and the user switches from one page to another, the code of the online consultant needs to be loaded immediately, and it will be loaded from the browser's cache, since was downloaded on the first hit.

Regular download code for JivoSite online consultant
( you need to replace # WidgetId # with the identifier of your widget).

<!-- BEGIN JIVOSITE CODE {literal} --> <script type='text/javascript'> (function(){ var widget_id = '#WidgetId#';var d=document;var w=window;function l(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '//code.jivosite.com/script/widget/'+widget_id; var ss = document.getElementsByTagName('script')[0]; ss.parentNode.insertBefore(s, ss);}if(d.readyState=='complete'){l();}else{if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();</script> <!-- {/literal} END JIVOSITE CODE --> 

')
JivoSite online advisor download code:
( you need to replace # WidgetId # with the identifier of your widget)

 <!-- BEGIN JIVOSITE CODE {literal} --> <script type='text/javascript'> (function(){ document.jivositeloaded=0;var widget_id = '#WidgetId#';var d=document;var w=window;function l(){var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '//code.jivosite.com/script/widget/'+widget_id; var ss = document.getElementsByTagName('script')[0]; ss.parentNode.insertBefore(s, ss);}//     JivoSite function zy(){ // EventListeners if(w.detachEvent){// IE8 w.detachEvent('onscroll',zy); w.detachEvent('onmousemove',zy); w.detachEvent('ontouchmove',zy); w.detachEvent('onresize',zy); }else { w.removeEventListener("scroll", zy, false); w.removeEventListener("mousemove", zy, false); w.removeEventListener("touchmove", zy, false); w.removeEventListener("resize", zy, false); } //   JivoSite if(d.readyState=='complete'){l();}else{if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}} //         var cookie_date = new Date ( ); cookie_date.setTime ( cookie_date.getTime()+60*60*28*1000); //24    d.cookie = "JivoSiteLoaded=1;path=/;expires=" + cookie_date.toGMTString(); } if (d.cookie.search ( 'JivoSiteLoaded' )<0){//,       ,  ,   EventListeners   ,           ,    JivoSite. if(w.attachEvent){//  IE8 w.attachEvent('onscroll',zy); w.attachEvent('onmousemove',zy); w.attachEvent('ontouchmove',zy); w.attachEvent('onresize',zy); }else { w.addEventListener("scroll", zy, {capture: false, passive: true}); w.addEventListener("mousemove", zy, {capture: false, passive: true}); w.addEventListener("touchmove", zy, {capture: false, passive: true}); w.addEventListener("resize", zy, {capture: false, passive: true}); } }else {zy();} })();</script> <!-- {/literal} END JIVOSITE CODE --> 

Source: https://habr.com/ru/post/447262/


All Articles