Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

defer_javascript should have more pagespeed.conf directives to help control it #481

Open
GoogleCodeExporter opened this issue Apr 6, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

amattie@gmail.com writes:

I believe defer_javascript should provide two Apache directives and perhaps an 
element attribute to allow for more precise control. I'd like to be able to 
exclude certain known external and inline scripts from being filtered. One key 
example of where it'd be useful is with Typekit scripts where you want the 
script to run before the page even begins rendering to prevent a 
flash-of-switching-fonts issue that's disruptive to the UX. Another example 
would be Google Analytics, where the script is run async but where it'd still 
be nice to have it run on its own track to keep the bounce rate stat as 
accurate as possible.

My thought is that the script attribute would look something like this:

<script src="//ga.com/analytics.js" data-mps-no-defer="true"></script>

The first Apache directives would look something like this, where the value is 
a wildcard match against the script tag's src attr:

ModPagespeedNoDeferJsSrc *analytics*

The second Apache directive is useful to fix issues where the content returned 
from the URL on the same server shouldn't be touched by defer_javascript. 
There's a very long story behind this, but it's necessary to make some parts of 
WordPress play nicely with this filter. I can research further and provide a 
detailed write up in another email if someone wants to dig into it. Anyway, in 
this directive, the value would be a wildcard match against the request URL:

ModPagespeedNoDeferJsReqUrl */upload*

Original issue reported on code.google.com by jmara...@google.com on 27 Jul 2012 at 9:53

@GoogleCodeExporter
Copy link
Author

Note that one aspect of this is already released but not yet doc'd 
(pagespeed_no_defer) but I left it in the bug description to keep the flow of 
Andrew's comment.

Original comment by jmara...@google.com on 27 Jul 2012 at 9:54

@GoogleCodeExporter
Copy link
Author

Original comment by jmara...@google.com on 15 Aug 2012 at 12:49

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

See a similar issue for rewrite_domains in Issue 1047.

Original comment by jmara...@google.com on 5 Feb 2015 at 2:34

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant