Answer the question
In order to leave comments, you need to log in
How to properly remove JavaScript and CSS blocking the display of the top of the page?
Struggling with this tip:
Remove the JavaScript and CSS blocking the display of the top of the page
Site on wordpress. Pursues sports interest. I'm trying to do according to this manual https://varvy.com/pagespeed/defer-loading-javascri...
Inserted this code before</body>
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
Answer the question
In order to leave comments, you need to log in
Fuck google pagespeed. There are JavaScript blocks that must be in the page header.
On bare js, everything is elementarily done.
before </body>
inserting
<script>
var script = document.createElement('script');
var link = document.createElement('link');
/*Подключаем стили*/
document.getElementsByTagName('head')[0].appendChild(link);
link.setAttribute('rel','stylesheet');
link.setAttribute('type','text/css');
link.setAttribute('href','css/style.css');
/*Подключаем скрипт*/
document.getElementsByTagName('head')[0].appendChild(script);
script.type = 'text/javascript';
script.src= 'js/script.js';
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question