Issue 1054 in modpagespeed: defer_js loading javascript twice

9 views
Skip to first unread message

modpag...@googlecode.com

unread,
Mar 19, 2015, 12:41:50 PM3/19/15
to mod-pagesp...@googlegroups.com
Status: Accepted
Owner: jef...@google.com
Labels: Type-Defect Priority-Medium

New issue 1054 by jef...@google.com: defer_js loading javascript twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Catchpoint is reporting that defer_js is double-loading javascript files:
http://blog.catchpoint.com/2015/03/18/pagespeed-third-party-issue/

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

modpag...@googlecode.com

unread,
Mar 19, 2015, 12:57:29 PM3/19/15
to mod-pagesp...@googlegroups.com

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:03:45 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #2 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Here's a simpler test case:

http://www.jefftk.com/type-psa-js?PageSpeed=off

Which has:

<script src="type-ps-js.js" type="psa/js"></script>
<script type="psa/js">
document.write("<h1>Inline: This shouldn't appear</h1>");
</script>

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:17:52 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #3 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Here are nine successive runs on
www.modpagespeed.com/defer_javascript.html?ModPagespeed=on&ModPagespeedFilters=defer_javascript
with Chrome: http://www.webpagetest.org/result/150319_9W_10E0/

None of them show double loading, and they all show rewrite_javascript.js
being loaded late.

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:19:53 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #4 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Here are nine runs of Chrome on
http://www.jefftk.com/type-psa-js?PageSpeed=off
http://www.webpagetest.org/result/150319_HW_10WF/

And nine runs of Safari: http://www.webpagetest.org/result/150319_3Q_10WJ/

None of them show loading of the type=psa/js external script file.

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:27:03 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #5 on issue 1054 by jmaes...@google.com: defer_js loading
javascript twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

I wonder if it's browser-version dependent?

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:35:28 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #6 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Here are nine runs of Chrome Canary on
http://www.jefftk.com/type-psa-js?PageSpeed=off
http://www.webpagetest.org/result/150319_7J_11WT/

All of them show loading of the type=psa/js external script file. So this
sounds like a recent Chrome change?

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:37:31 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #7 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Actually, not all of the Canary runs. Runs #2 and #4 didn't load it.

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:56:23 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #8 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

There are going to be some races depending on whether the preload scanner
runs at all. If we're never blocked on js, for example, I think it might
not run. So here's a new test that does some js busywaiting before listing
any psa/js scripts: http://www.jefftk.com/type-psa-js2?PageSpeed=off

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:57:21 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #9 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Possibly relevant Chrome bug:
https://code.google.com/p/chromium/issues/detail?id=329531

modpag...@googlecode.com

unread,
Mar 19, 2015, 1:59:57 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #10 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Here are WebPageTest runs on first Chrome and then Chrome Canary for the
new test page: http://www.webpagetest.org/result/150319_DD_12NC/
http://www.webpagetest.org/result/150319_MJ_12MZ/

The new test page doesn't seem to be eliciting different behavior from the
old one.

modpag...@googlecode.com

unread,
Mar 19, 2015, 2:02:11 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #11 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

From the discussion on 329531 it sounds like the preload scanner may or may
not initiate fetches for scripts with unknown types, but this is actually
ok. Really we just don't want duplicate loads, and the only one of those
I've been able to reproduce was that Safari run.

modpag...@googlecode.com

unread,
Mar 19, 2015, 2:05:22 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #12 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Running more Safari tests. On
http://www.jefftk.com/type-psa-js2?PageSpeed=off it doesn't fetch the
external js file at all, which is reasonable.
http://www.webpagetest.org/result/150319_HB_1313/

On
www.modpagespeed.com/defer_javascript.html?ModPagespeed=on&ModPagespeedFilters=defer_javascript
where we got the double load before it gets a double load every time.

http://www.webpagetest.org/result/150319_YF_131A/

modpag...@googlecode.com

unread,
Mar 19, 2015, 5:45:00 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #13 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Testing in Chrome Canary on my mac I'm seeing double loading in devtools
(attached) on
http://www.modpagespeed.com/defer_javascript.html?ModPagespeed=on&ModPagespeedFilters=defer_javascript

My guess is that the preload scanner initiates a fetch, and then defer_js
initiates a fetch, and Chrome's not properly figuring out that there's
already an active fetch for that resource.

One difference between the two requests is that the first one has its
Accept header set to "*/*" while the second has "image/webp,*/*;q=0.8".

Attachments:
chrome-canary-double-loading.png 185 KB

modpag...@googlecode.com

unread,
Mar 19, 2015, 5:46:34 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #14 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Actually, I just realized that the devtools response shown in #13 indicates
three loads of rewrite_javascript.js. It's possible that I'm getting bad
results from reloading with Shift+Ctrl+R.

modpag...@googlecode.com

unread,
Mar 19, 2015, 5:52:08 PM3/19/15
to mod-pagesp...@googlegroups.com

Comment #15 on issue 1054 by jef...@google.com: defer_js loading javascript
twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

Yes, after clearing cache we still see three entries in devtools but the
second two are from cache. This kind of makes sense: I see why we would
get one for the preload scanner and then one when we change the type, but I
don't see why we would get a third one.

Attachments:
chrome-canary-after-cache-clear.png 158 KB

modpag...@googlecode.com

unread,
Apr 8, 2015, 2:24:25 PM4/8/15
to mod-pagesp...@googlegroups.com

Comment #16 on issue 1054 by jcro...@google.com: defer_js loading
javascript twice
https://code.google.com/p/modpagespeed/issues/detail?id=1054

this issue has been migrated to github:
https://github.com/pagespeed/mod_pagespeed/issues/1054
Reply all
Reply to author
Forward
0 new messages