A
A
Aricus2019-04-10 17:13:45
JavaScript
Aricus, 2019-04-10 17:13:45

How to take a part of js out of the main thread?

For the first time trying to optimize the site (on wordpress). Based on the PageSpeed ​​Insights scores, the significant reduction in image size did not affect the overall scores. Judging by this piece
5cadf89625d7d090711588.png
, the process is very slowed down by three js scripts that are not necessary for the initial operation of the page. This is Yandex metric, youtube player and business messenger. Is it possible to somehow transfer them from the main thread to another? Judging from the above data, this will reduce the load time for interaction by 5 seconds for mobile and 1.4 seconds for desktop.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2019-04-11
@Aricus

Hit the metric for sure.
YouTube should be removed under JS, instead of a player, a picture -> when clicked, a player is inserted.
Youtube takes a long time to load.
Live site is not a fact that it affects so much, but you can make a feint with your ears

setTimeout(function(){
(function(){ var widget_id = '***';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);}}})();
}, 3000);

In general, all WordPress optimization is:
1. Run images through https://compressor.io/
2. And install some W3 Total Cache + enable all sorts of minifications, etc.
3. Throw all widgets into setTimeout
At the output, get 90-100 for desktop and 80-100 for mobile on PageSpeed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question