mod_pagespeed not deferring javascript

1.4k views Asked by At

I am trying to defer my javascript loading according to Google's pagespeed analysis of my site. However they are complaining about the following:

http://www.example.com/pagespeed_static/js_defer.pbrP1whUgE.js

which is the code that is automatically generated by them. How can I defer this to load at the end?

In my pagespeed.conf file I have the following set:

ModPagespeedEnableFilters defer_javascript

On an additional note, has anyone else noticed that Google Chrome's audit's complain about using adsense and recommend optimizing no optimizable code?

1

There are 1 answers

0
Alvaro Flaño Larrondo On

I'm not completly sure but I think that to enable defer_javascript you have to change the RewriteLevel to PassThrough and manually enable the filters you want (this will override the CoreFilters that are enabled by default).

An example from the official site:

Apache:

ModPagespeedRewriteLevel PassThrough
ModPagespeedEnableFilters combine_css,extend_cache,rewrite_images
ModPagespeedEnableFilters rewrite_css,rewrite_javascript

Nginx:

pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters combine_css,extend_cache,rewrite_images;
pagespeed EnableFilters rewrite_css,rewrite_javascript;