E
E
Eugene2017-04-20 10:06:03
Google
Eugene, 2017-04-20 10:06:03

Google PageSpeed ​​swears that scripts interfere with site loading?

Welcome all! Is there a layout where scripts are included before </body>, but Google Page Speed ​​shows that they prevent the site from loading? Tell me why is that?
f531cdf3994c4fadaad843ca6e17907e.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2017-04-26
@klyo

Include JS like this before the closing body:

<script>var scr = {"scripts":[
    {"src" : "ваш_скрипт.js", "async" : false},
    ]};!function(t,n,r){"use strict";var c=function(t){if("[object Array]"!==Object.prototype.toString.call(t))return!1;for(var r=0;r<t.length;r++){var c=n.createElement("script"),e=t[r];c.src=e.src,c.async=e.async,n.body.appendChild(c)}return!0};t.addEventListener?t.addEventListener("load",function(){c(r.scripts);},!1):t.attachEvent?t.attachEvent("onload",function(){c(r.scripts)}):t.onload=function(){c(r.scripts)}}(window,document,scr);
  </script>

In order not to slow down the loading of the page. Then Google PageSpeed ​​will not swear at these files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question