Link to home
Start Free TrialLog in
Avatar of seopti
seopti

asked on

Remove Render-Blocking JavaScripts

Google suggests this, but I don't quite get what they mean with "deferredfunctions.js".
If I have 8 .js files which are not deferred how do I insert them in deferredfunctions.js - do I combine them?

https://developers.google.com/speed/docs/insights/BlockingJS

<script type="text/javascript">

 // Add a script element as a child of the body
 function downloadJSAtOnload() {
 var element = document.createElement("script");
 element.src = "deferredfunctions.js";
 document.body.appendChild(element);
 }

 // Check for browser support of event handling capability
 if (window.addEventListener)
 window.addEventListener("load", downloadJSAtOnload, false);
 else if (window.attachEvent)
 window.attachEvent("onload", downloadJSAtOnload);
 else window.onload = downloadJSAtOnload;

</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm not sure of your exact problem, but usually having all Javascripts at the end of the BODY should not block most important content to load before starting loading javascript. But I guess you've already know that.. ;)