Skip to content
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

Option to Preload any CSS and JS file to address Preload key requests recommendation #3432

Closed
WordPresseur opened this issue Dec 22, 2020 · 5 comments
Labels
feature request Indicates new feature requests module: preload priority: medium Issues which are important, but no one will go out of business. waiting for feedback

Comments

@WordPresseur
Copy link
Contributor

According to what Google explains here: https://developers.google.com/web/tools/lighthouse/audits/preload

WP Rocket only do this for CSS files when the Optimize CSS Delivery feature is enabled and, since v3.6 of WP Rocket, for font files.

But it happens that PageSpeed Insight points out JS or other CSS files and we have to advise to use another plugin to do that preload request.

Maybe we could have a Preload Files section from the Preload tab.

@arunbasillal arunbasillal added feature request Indicates new feature requests module: preload priority: medium Issues which are important, but no one will go out of business. waiting for feedback labels Dec 22, 2020
@ScottTravisHartley
Copy link
Contributor

Another note, most of the time i only get this notice if a client site is using @import to process a CSS file there was another issue pertaining to possibly adding support to process the @import request this might also clear the warning at least for the CSS files.

JS wise the only time I really get this is when a file is deferred say via cloudflare's rocket loader but is integral for some above the fold content most of the time its JQuery but there isn't necessarily a good way to resolve that one without adding support for preload in which case i do so via Perfmatters atm.

@socialpreneur
Copy link

Since minified file names are almost always different, it would be great if WP Rocket can auto add preload, but that option should be selectable by users. I also use perfmatters to set preload, but to do so, I always have to exclude the preload file from minification of WP Rocket.

@GeekPress
Copy link
Contributor

The recommendation to preload CSS is only when the CSS file is inserted by a JS file.

This is exactly what is explained here:
https://developers.google.com/web/tools/lighthouse/audits/preload

Why?
Because the browser doesn't know it has to load this CSS file until to load the JS which will load the CSS file.

All CSS files already declared with a tag doesn't need to be preloaded. It's totally useless.

The CSS files need to be preloaded only when we are using CPCSS. It's the best way to avoid FOUC and the only reason to preload them.

All CSS is inserted into the header. It's already loaded in priority based on their implementation on HTTP1.

On HTTP2 CSS is loaded in priority by the browser. Even if the CSS is loaded synchronously.

This is why most of the time the Preload Key request is related to fonts. The fonts are declared into the CSS which isn't yet loaded/parsed by the browser. We have to indicate to the browser that files need to be loaded as soon as possible (before the browser could discover them).

From a user point of view, we can totally see the benefits of adding preload for assets. As the file is listed in the « Preload Key request », they want to fix that.

In the meantime, we should be careful to not have our users preloading all assets. My concern is this point: preloading everything and especially all JS files isn't a good thing to do. We must recommend our users to preload only CSS/JS files listed in the Preload Key request recommendations.

@GeekPress
Copy link
Contributor

I'm closing this one in favor of #3539 which will provide an automatic solution for @import in CSS files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Indicates new feature requests module: preload priority: medium Issues which are important, but no one will go out of business. waiting for feedback
Projects
None yet
Development

No branches or pull requests

6 participants