PageSpeed Insights complains about Nginx+PageSpeed!

351 views
Skip to first unread message

KF

unread,
Jul 1, 2014, 9:42:26 PM7/1/14
to pagespeed-ins...@googlegroups.com
Hi guys,

I'm optimizing a website using Nginx+Pagespeed and I use the defer_javascript feature. When I run the site through PageSpeed it complains that the site needs to Eliminate render-blocking JavaScript and CSS in above-the-fold content with the file /pagespeed_static/js_defer.eX_CQDtaZA.js. Funny enough, this is the file autogenerated by the PageSpeed nginx plugin. How would I go about fixing this? I can't find an option to make the auto-generated JS file a deferred or async load? 

The score on my client's website used to be 90+ on both mobile and web. Now with the new metrics in place, it hovers around 70/85. The site: www . rksv . in

Miguel García Sánchez - Colomer

unread,
Jul 2, 2014, 4:04:15 AM7/2/14
to pagespeed-ins...@googlegroups.com
Hi,
i think that you are not deferring the call to <script type="text/javascript" src="/pagespeed_static/js_defer.eX_CQDtaZA.js"></script>. You have it before the </body> but i think you have to use this to make a "real deferred call":

<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "/pagespeed_static/js_defer.eX_CQDtaZA.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>
 Or if it's possible and don't need to be deferred you can make it async:

<script type='text/javascript'>

(function(){
var bsa = document.createElement('script');
bsa.type = 'text/javascript';
bsa.async = true;
bsa.src = '/pagespeed_static/js_defer.eX_CQDtaZA.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);
})();

</script>

or this async way:

<script type='text/javascript'> (function(){ var s=document.createElement('script'); s.type='text/javascript'; s.async=true; s.src='/pagespeed_static/js_defer.eX_CQDtaZA.js'; var h=document.getElementsByTagName('script')[0]; h.parentNode.insertBefore(s,h); })();  </script>

Carlos could help too, let's see what he says.

Best regards,

KF

unread,
Jul 2, 2014, 4:06:26 AM7/2/14
to pagespeed-ins...@googlegroups.com
Hi Miguel,

Thanks for the reply! The issue is, I don't generate this JS file in my PHP/Wordpress code. It's the Nginx+Pagespeed plugin that takes my JS file, probably minifies/compresses it, and places it in a new file called js_defer.XXXXXXX.js. It also places the <script type=""></script> code in the bottom of my page automatically.

Miguel García Sánchez - Colomer

unread,
Jul 2, 2014, 4:21:35 AM7/2/14
to pagespeed-ins...@googlegroups.com
Hi, ok. You'll get a good socre.

Best regards!

Carlos Lizaga Anadon

unread,
Jul 2, 2014, 9:36:38 AM7/2/14
to pagespeed-ins...@googlegroups.com
Do you have any page link so we can check how's the page architecture in order to check it? 

Best Regards! 

Dave Mankoff

unread,
Jul 2, 2014, 9:41:00 AM7/2/14
to mod-pagesp...@googlegroups.com
Howdy folks. This discussion is probably better suited for the mod-pagespeed-discuss list. They'll be able to answer specific questions about settings in the module.

+mod-pagespeed-discuss
-pagespeed-insights-discuss


-dave mankoff

Manish Jain

unread,
Feb 18, 2017, 3:01:18 AM2/18/17
to pagespeed-insights-discuss
Hi KF,

I am also facing the same issue, Did you find any suitable solution for the same.

Thanks.

André Böker

unread,
Feb 20, 2017, 4:21:50 PM2/20/17
to pagespeed-insights-discuss, mod-pagesp...@googlegroups.com
Hi Dave,

when and where are you going to post informations about the changes on google pagespeed insights? 
There are a lot of people looking for those informations. 

best regards
André
Reply all
Reply to author
Forward
0 new messages