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

Load CSS Conditionally #23271

Closed
kamauwanjoroge opened this issue Jun 18, 2020 · 8 comments
Closed

Load CSS Conditionally #23271

kamauwanjoroge opened this issue Jun 18, 2020 · 8 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Performance Related to performance efforts

Comments

@kamauwanjoroge
Copy link

kamauwanjoroge commented Jun 18, 2020

Is your feature request related to a problem? Please describe.
The block editor loads all of its CSS in the front end rather than conditionally depending on the blocks being used

Describe the solution you'd like
Make the CSS load conditionally depending on the blocks being used and also on the pages and posts they are on, not the whole block CSS font everywhere.

Describe alternatives you've considered
None since this is a core feature. I load all my CSS files conditionally depending on where they are being used, and the block editor is adding two additional files per page! Hence, increasing page weight.

@oxyc
Copy link
Member

oxyc commented Jun 18, 2020

This was recently fixed #22754

@kamauwanjoroge
Copy link
Author

kamauwanjoroge commented Jun 18, 2020

@oxyc has this been merged with the plugin in the repository?
Edit: I see not yet. Will wait and see.

@oxyc
Copy link
Member

oxyc commented Jun 18, 2020

No it hasn't been released yet. If you want to test it you can either build the plugin locally from master (clone it into the plugins folder and run nvm use; npm install; npm run build or just manually change the files the commit does: https://github.com/WordPress/gutenberg/pull/22754/files

@gziolo
Copy link
Member

gziolo commented Jun 19, 2020

This was recently fixed #22754

Yes, it should be addressed with this PR. Let’s close this issue. Feel free to reopen next week after the Gutenberg plugin release if it doesn’t work as expected.

@gziolo gziolo closed this as completed Jun 19, 2020
@gziolo gziolo added [Type] Performance Related to performance efforts [Feature] Block API API that allows to express the block paradigm. labels Jun 19, 2020
@kamauwanjoroge
Copy link
Author

@gziolo will do.

@kamauwanjoroge
Copy link
Author

It does not work for core blocks.

@gziolo
Copy link
Member

gziolo commented Jun 25, 2020

Yes, all core blocks have JavaScript and CSS code bundled together. We plan to optimize the whole approach later this year according to the plan shared by @saramarcondes in this comment #2768 (comment). Once we have support for lazy loading blocks we will split core blocks into individual bundles that load only when necessary.

@kamauwanjoroge
Copy link
Author

Will be on the lookout. All my (minified) CSS files are below 20kb and the core blocks add 56kb (minified) into my combined CSS file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Performance Related to performance efforts
Projects
None yet
Development

No branches or pull requests

3 participants