-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Split core blocks assets loading #25220
Conversation
Size Change: +604 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
Conflicts: packages/block-library/src/cover/block.json packages/block-library/src/group/block.json packages/block-library/src/separator/block.json
* Add preformatted block styles and font settings. * Add font size fallback. * Remove unnecessary overflow property and use `pre-wrap` instead. This is a more elegant solution compared to the previous one, which relied on overflow. * Remove editor.scss * Remove CSS custom property. This is the theme's job. For more information, see #27672 * Add stylesheet to `block.json` file This is added due to new requirement implemented in #25220 Co-authored-by: Ari Stathopoulos <[email protected]> * Add preformatted block to theme-json.md specs. * Fix preformatted block support information on theme-json.md specs. Co-authored-by: Ari Stathopoulos <[email protected]>
Is correct to say that this does not work for JS files? I mean, if I create a frontend js file and register to block, this will be loaded site wide. Is this true? |
With this PR |
I can confirm. 😄 Core blocks don't enqueue any JS on the frontend so nothing breaks there. For 3rd-party blocks the JS & CSS get enqueued only when the block is used on a page. I confirmed that this works as expected using the WooCommerce "All Reviews" block. When it's present on a page its frontend-script loads, and it doesn't load on pages that don't contain it 👍 Since core blocks don't currently ship any frontend JS, an implementation for that was not added in this PR to avoid adding unused code. It's easy to add it once we need it. |
…ore blocks Related Gutenberg PR: WordPress/gutenberg#25220. It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged. Props aristath. See #50328. git-svn-id: https://develop.svn.wordpress.org/trunk@49850 602fd350-edb4-49c9-b593-d223f7449a82
…ore blocks Related Gutenberg PR: WordPress/gutenberg#25220. It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged. Props aristath. See #50328. git-svn-id: https://develop.svn.wordpress.org/trunk@49850 602fd350-edb4-49c9-b593-d223f7449a82
…ore blocks Related Gutenberg PR: WordPress/gutenberg#25220. It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged. Props aristath. See #50328. Built from https://develop.svn.wordpress.org/trunk@49850 git-svn-id: http://core.svn.wordpress.org/trunk@49569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…ore blocks Related Gutenberg PR: WordPress/gutenberg#25220. It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged. Props aristath. See #50328. Built from https://develop.svn.wordpress.org/trunk@49850 git-svn-id: https://core.svn.wordpress.org/trunk@49569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Description
Only load core-blocks assets when the blocks are used.
This is a continuation of #22754 while researching ways to more efficiently load assets for rendered blocks. Also related to #5445
What this PR does:
style.scss
to multiple stylesheets, one per-block.style
andeditorStyle
in allblock.json
files that needed itsplit-block-styles
theme-support and reverts Release: WordPress 5.5 beta 1 finishing touches #23708 if the theme-support is added.How to test:
Enable an FSE theme. Styles will automatically load separately for each block that exists on a page in the frontend. (I am testing with https://github.com/aristath/q)
Checklist: