link rel="preload" double downloads resources loaded by imported html files |
||||||
Issue descriptionChrome 55.0.2883.95 (64-bit) (Mac) See https://github.com/andybons/preload/tree/master/static/import for an example of this. index.html: <link rel="preload" href="app.js"> <link rel="import" href="import.html"> import.html: <script src="app.js"></script> app.js: console.log('this is the app'); Expected behavior: app.js is not requested twice. No console warning about it not being used after window.onload. Actual behavior: app.js is loaded twice both from Initiator (index):-Infinity. Warning is shown in the console: The resource http://localhost:8080/import/app.js was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it wasn't preloaded for nothing.
,
Feb 10 2017
I think what's happening here is that you forgot to add as="script" to your link rel=preload element(s). The script tag doesn't see the former link rel preload as something it could use. +Paul Irish: could we make the warning a bit more useful by hinting at the lack of as="script" as the root cause of the issue?
,
Feb 10 2017
,
Feb 10 2017
Thanks. That fixed it, though I had to remove the crossorigin="anonymous" attribute in my prod app or else it will double-download. Was it being misused? Is this a separate bug?
,
Feb 10 2017
Can you clarify which crossorigin attribute you had to remove? Can you post links to a working example vs. a non-working one?
,
Feb 10 2017
Currently, on skia-review.googlesource.com, you can check the source of index.html and see the following line: <link rel="preload" href="https://cdn.googlesource.com/polygerrit_ui/280.0/elements/gr-app.js" crossorigin="anonymous"> When I change this to: <link rel="preload" href="https://cdn.googlesource.com/polygerrit_ui/280.0/elements/gr-app.js" as="script" crossorigin="anonymous"> It still double downloads, but when I remove the crossorigin attribute: <link rel="preload" href="https://cdn.googlesource.com/polygerrit_ui/280.0/elements/gr-app.js" as="script"> It works as intended. Hope this was clear. The example in the first comment also shows this if you follow the same steps.
,
Feb 14 2017
FWIW: demo link: https://rawgit.com/andybons/preload/master/static/import/index.html Yoav, can we add text about missing 'as' in the warning? How about: > The resource https://rawgit.com/andybons/preload/master/static/import/app.js was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.
,
Mar 29 2017
,
Jan 1 2018
Apologies for dropping the ball on this... Patch at https://chromium-review.googlesource.com/c/chromium/src/+/846980
,
Jan 2 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/585988dafb896f900f565db97d7cc48d78e8801c commit 585988dafb896f900f565db97d7cc48d78e8801c Author: Yoav Weiss <yoav@yoav.ws> Date: Tue Jan 02 08:18:53 2018 Clearer warning when preload resource is not used. There's some confusion when preloaded resources are not used, and the current warning message is not clear enough. On the issue Paul Irish suggested a better warning message, that may help reduce the confusion. This CL implemented that message. Bug: 678429 Change-Id: I4d7bda73d243de9d323a007ee336dfd571586d64 Reviewed-on: https://chromium-review.googlesource.com/846980 Reviewed-by: Charlie Harrison <csharrison@chromium.org> Commit-Queue: Yoav Weiss <yoav@yoav.ws> Cr-Commit-Position: refs/heads/master@{#526448} [modify] https://crrev.com/585988dafb896f900f565db97d7cc48d78e8801c/third_party/WebKit/LayoutTests/fast/dom/HTMLLinkElement/link-preload-unused-expected.txt [modify] https://crrev.com/585988dafb896f900f565db97d7cc48d78e8801c/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
,
Jan 2 2018
,
Mar 8 2018
Sorry guys, understand you guys recently changed the message but it needs another change.
,
Mar 8 2018
The current message says this: The resource http://use.typekit.net/some/font/with/some/random/uid/here?withsomeargs=1 was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it Please make sure it has an appropriate `as` value and it is preloaded intentionally.
,
May 8 2018
This is because you need to add `crossorigin` to your link tag (or header). The message could be changed to indicate that sometimes (eg, for fonts) you need to specify `crossorigin` when preloading, otherwise the preload is not useful and the file is loaded twice (once by preload without `crossorigin` set, and one from the page, this time with `crossorigin` set) |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by y...@yoav.ws
, Jan 6 2017Owner: y...@yoav.ws
Status: Assigned (was: Untriaged)