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

Conditional CSS preload #33

Closed
ggeorgovassilis opened this issue May 3, 2020 · 5 comments
Closed

Conditional CSS preload #33

ggeorgovassilis opened this issue May 3, 2020 · 5 comments
Labels

Comments

@ggeorgovassilis
Copy link

Issue #30 preloads prettify.css. This has a drawback when optimisations like the Fast Velocity Minify plugin are active, which bundles all CSS into a single file. In that case the preloader still fetches prittify.css issuing an unnecessary http request in every page. Preloading should be conditional on a setting.

@kasparsd
Copy link
Owner

kasparsd commented May 3, 2020

Thanks for reporting the issue!

The prettify.css is loaded via JS instead of wp_enqueue_script() so it shouldn't be possible for concatenation plugins to include it in the bundle. I'm not seeing the issue with https://github.com/kasparsd/minit for example.

You bring up a good point, though -- that preload only makes sense when the prettify.css is going to be actually used. I wonder if the prettify library loads it on every page or we're triggering false preloads when the CSS file isn't actually needed.

@ggeorgovassilis
Copy link
Author

Thank you for the quick response. I worked around the issue by commenting prettify_preload_code_styles

@kasparsd
Copy link
Owner

kasparsd commented May 3, 2020

I just posted an alternative solution in the wiki that should allow you to keep the plugin updated and have the preload disabled.

Also, could you please confirm if and how prettify.css get's included in the FVM bundle even when it's added via JS? Is that because of that preload rule?

@ggeorgovassilis
Copy link
Author

Also, could you please confirm if and how prettify.css get's included in the FVM bundle even when it's added via JS? Is that because of that preload rule?

It's <link rel="preload"> inlined into the page's html. The FVM bundle already includes prettify.css, so removing the preloader doesn't affect functionality.

@kasparsd
Copy link
Owner

kasparsd commented May 3, 2020

Shouldn't it remove the preload tag if it already inlined its content?

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

No branches or pull requests

2 participants