New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome Warning message regarding not using preloaded chunks #8

Closed
stevenfitzpatrick opened this Issue Feb 2, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@stevenfitzpatrick
Copy link

stevenfitzpatrick commented Feb 2, 2017

Just trying out this plugin for two chunks generated by webpack code splitting, everything seems to working fine but in console I am getting these warnings.

The resource http://localhost:8080/98196ebdaabca2c98261.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.

Now the error makes sense, but it could take the user a few seconds to navigate to the route which requires these chunks. Is there anyway to stop this error message ?

I.e I preload these code-splitting chunks as follows

<link rel="preload" href="98196ebdaabca2c98261.js" as="script">
<link rel="preload" href="0f4f2b938549bee12ab7.js" as="script">

but they are not loaded on "home" route, only when the user navigates to i.e. "favourites"

Edit : I guess I should be using prefetch

@addyosmani

This comment has been minimized.

Copy link
Contributor

addyosmani commented Feb 2, 2017

Thanks for asking a good question. Unused preloads in Chrome will trigger a console warning ~3 seconds after onload. This happens when the resource isn't being consumed (e.g you're not trying to use a script you've preloaded) in a timely manner.

If the resource is needed for the current navigation & will be used, go for preload. If the resource is needed beyond that (and you're not using in the current nav), I'd go for prefetch.

@stevenfitzpatrick

This comment has been minimized.

Copy link

stevenfitzpatrick commented Feb 2, 2017

Thanks for replying, I was just going to try and close this before I saw your reply, as I felt stupid after reading more about the difference between prefetch and preload.

My first impression was preload was the cool new thing in town to replace prefetch. But I guess there is still a need for both.

Thanks for the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment