Repository navigation
what is the benefit of using per-block JS/CSS? #24
|
what is the benefit of using dedicated js/css via block.json |
Answered by
fabiankaegy
Mar 30, 2022
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 |
0 replies
Answer selected by
fabiankaegy
|
Thank you @fabiankaegy |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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