function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.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;
Ok so I'm using googles tip to defer loading of jQuery and fix any Render-blocking issue.
The issue happens when you are blocking external script during parsing which is loading jQuery or any other large javascript files that is not needed to render the above-the-fold region. So with the code above the issue is fixed. BUT I have one problem I have codes that run $(document).ready() but it bugs up because jQuery hasn't loaded yet.
How do I find out if jQuery has finished loading?
jQueryload within theHTMLitself?$(document).ready(), just put thejQueryload in theheadof yourHTML, rather than injecting it with ascript.