-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Only load assets for existing blocks on the frontend #25742
Comments
I currently have 2 PRs with completely different implementations. #25220In this PR the pre-existing structure and calls are used. It adds stylesheet definitions to #25118In this PR a new CC @youknowriad |
This is something that needs a lot of eyes on it. cc @mcsf @mtias @saramarcondes @jorgefilipecosta @gziolo At first sight, I have more a preference for the first approach, as it's more declarative and controlled and can scale well to JavaScript as well. There's no reason to not load the JS of each block (if existing) separately as well. |
Ideally I'd like to have a mix of both.
With that in mind, there is absolutely no reason to make an additional request in the browser to get the stylesheet for a paragraph block or an audio block... They are both too small and inlining them would make a lot more sense. Fewer requests, faster response times. For the cover block or social-links it makes sense to load them as stylesheets, they are 8kb+. That is the part I like most about the 2nd implementation |
Closing this one, #25220 was merged. |
This is a continuation of #5445. That issue has grown too much to be usable and it's difficult to get an overview without reading 50+ long threads.
The gist and what we want to accomplish is to only load styles and scripts for blocks that exist on a page when rendering that page on the frontend. There are many ways to accomplish that, and #22754 implemented it for 3rd-party blocks successfully.
However, core blocks don't currently do that and instead we load a monolithic stylesheet with styles for all blocks.
With Full Site Editing coming soon, this becomes increasingly important for future sustainability.
Steps we need to take in order to accomplish this:
block.json
files for all blocks, to include references to the stylesheet handlesThe text was updated successfully, but these errors were encountered: