-
Notifications
You must be signed in to change notification settings - Fork 801
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
CSS Concatenating: jetpack.css loads all styles, even if they've been manually dequeued #1258
Comments
Yes, that's a known issue with Jetpack 3.2. Jetpack now concatenates its CSS into a You can follow our progress in #1235. I'll close this issue as it's a duplicate. |
@jeherve - Thanks Jeremy. Didn't catch that when I opened the ticket. Cheers! |
Reopening this since #1235 was closed when fixing the CSS specificity issue. This bug is regarding how we still include all stylesheets in |
Is there a core action we can track for when a stylesheet is dequeued? |
Can we track all |
Just checked, there isn't an action that does this. |
Reopening this, as it is still a valid enhancement. |
I came across this thread after a google search led me to issue #15734, which is closed because it's basically a duplicate of this issue. I'm glad this is still open because it is a valid enhancement, what I am working on now to address it is adding a filter to disable the concatenation and then using the "Asset CleanUp" plugin to disable the files I don't need and letting my caching plugin concatenate everything else into as few files as possible. Hopefully others will find this approach helpful. |
This issue has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation. |
This was also brought up in this post:
As we had discussed in #7656, we should try to find a way to not include everything in the concatenated file if it is not needed. |
I'd like to come back to this issue and summarize the conversations above a bit: We currently use this to enqueue a concatenated That This has a few inconvenients:
Also of note, this is only about CSS. We do not have anything similar for the different JavaScript files needed by different Jetpack modules. I'll cc @Automattic/heart-of-gold on this conversation, since they may have some useful input on performance here. |
This is pretty key, IMO. There's no benefit to end-users when HTTP/2 is enabled, and it can often be worse than just loading the CSS that's needed. |
It depends. Concatenating resources can still assist with improving compression, as compressing similar text patterns together is more efficient than separately. Based on a quick test, Brotli compression brings jetpack.css down from 99.7 kB to 17.1 kB. Reviewing the contents of the uncompressed 99.7 kB, the big parts appear to be:
My gut feeling is that it's worth splitting out the bigger items that aren't always needed into their own files (e.g.: carousel), but it's better to keep the tiny files and the non-optional files combined. It's hard to estimate exactly how much of the compressed size would be saved by removing things like carousel, but we can expect at least a few kB savings there, which makes it worthwhile IMHO. But we should probably test actual compressed sizes with different bundling to verify my gut feeling. Compression is a little hard to predict without testing. :) |
17.1kb is not an insignificant amount of code, especially on slower connections and older devices.
How would you define "non-optional"? I don't use Jetpack for a single front-end feature. |
One specific case that we could handle is when no feature using jetpack.css on the front end is activated. Then we should not load it at all. |
See #1258 We currently enqueue a `jetpack.css` concatenated CSS file as soon as your site is connected to WordPress.com. That jetpack.css file is built off a list of stylesheets from individual modules that are not enqueued when the concatenated file is enqueued. In this commit, we add a new condition: for the file to be enqueued, there has to be at least 2 modules that need it. This will avoid loading the file when it wouldn't even be needed at all. This requires a change in the implementation: we now check for active modules before we dequeue individual assets / enqueue jetpack.css. This is an additional call to get an option (( new Modules() )->get_active()). This also means that the new $modules_with_concatenated_css variable will need to be kept updated. Note that this is only a partial improvement. We still need to address the larger questions around the implementation in today's world, as discussed here: #1258 (comment)
As of this weekend, I'm now seeing
jetpack.css
loading on the front-end, even though the only feature I'm using in Markdown. This file contains CSS for all Jetpack features.I'm currently overriding this behavior using this snippet in
functions.php
, but this feels like it may be a bug:More info: https://www.twirlingumbrellas.com/wordpress/remove-deregister-jetpack-contact-form-styles/
The text was updated successfully, but these errors were encountered: