Checking through pagespeed insights got this error as "Eliminate render-blocking JavaScript and CSS in above-the-fold content".
Javascript:
http://www.staging.website.com/theme/js/jquery.min.js
http://www.staging.website.com/theme/js/bootstrap.min.js
http://www.staging.website.com/theme/engine1/jquery.js
CSS:
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css
http://maxcdn.bootstrapcdn.com/…t-awesome/4.3.0/css/font-awesome.min.css
http://cdn.bootcss.com/animate.css/3.5.1/animate.min.css
http://www.staging.website.com/theme/css/demo.css
http://www.staging.website.com/theme/css/aboutus.css
I have tried these code for eleminating render blocking javascript.
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "http://www.staging.website.com/theme/js/jquery.min.js";
element.src="http://www.staging.website.com/theme/js/bootstrap.min.js
element.src="http://www.staging.website.com/theme/engine1/jquery.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
I have tried this javascript code in my file as well as in and in footer as well It is working fine but the js files is not loading at all.
And for css i have tried this but css is not loading
<script>
/*!
loadCSS: load a CSS file asynchronously.
*/
function loadCSS(href){
var ss = window.document.createElement('link'),
ref = window.document.getElementsByTagName('head')[0];
ss.rel = 'stylesheet';
ss.href = href;
// temporarily, set media to something non-matching to ensure it'll
// fetch without blocking render
ss.media = 'only x';
ref.parentNode.insertBefore(ss, ref);
setTimeout( function(){
// set media back to `all` so that the stylesheet applies once it loads
ss.media = 'all';
},0);
}
loadCss('styles.css');
</script>
<noscript>
<!-- Let's not assume anything -->
<link rel="stylesheet" href="styles.css">
</noscript>