what is the benefit of using per-block JS/CSS? #24
-
what is the benefit of using dedicated js/css via block.json |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The main benefit is that you automatically get free frontend code splitting. The assets of your block will only get loaded on the page if the block is actually used on the page. Which especially for CSS was very hard to do previously in the WordPress context. https://gutenberg.10up.com/reference/Themes/styles#block-specific-styles |
Beta Was this translation helpful? Give feedback.
-
Thank you @fabiankaegy |
Beta Was this translation helpful? Give feedback.
The main benefit is that you automatically get free frontend code splitting. The assets of your block will only get loaded on the page if the block is actually used on the page. Which especially for CSS was very hard to do previously in the WordPress context.
https://gutenberg.10up.com/reference/Themes/styles#block-specific-styles