-
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
Improve loading method for block Javascript #29606
Comments
Just to clarify, is this about the editor or the frontend? If it's about the editor, I'd suggest closing this in favor of #27268 For the frontend, we don't have many blocks adding JS to the frontend (0 in core blocks) but a declarative approach (like the CSS one) is explored in #29537 I know @sarayourfriend did some work on the former too but there's a lot of complexities there. |
EDIT: Sorry for confusion, I'm still trying to understand myself if blocks' JS are only loaded when they appear on a page #29537 (comment) I need to learn more about this. As for number 5, I agree that this is a problem (and it has been for years with wordPress, with keeping track of which shortcodes are being used on a site; I've been using find-my-blocks with some success. |
The goal is to eventually have a loading of all assets optimized on the front and correlated with blocks used. The only remaining use case that I'm aware of is infinite scrolling that loads more content and can contain additional blocks that would have to dynamically inject CSS and JS. @aristath can provide a more detailed answer as he explored everything for CSS support. |
Yeah, infinite-scroll is not yet addressed. The main issue is there is currently nothing implementing infinite-scroll so it was impossible to test and fix it properly. I have some ideas and a proof-of-concept to add these via JS, but until we actually have something to test infinite-scroll there's not much that can be done. |
What problem does this address?
Performance. All block styles are loaded at pageload if the block plugin is installed and active in the site whether or not the block is in use on the page. Leads to many JS files enqueue at runtime and potential performance drain on sites which lack efficient CDN and cache.
Not sure how many plugins enqueue additional scripts that run on the front end of the site and how and when that will factor into this concern. Regarding that same conversation, I am not sure how the admin edit page screen or whatever other screen is loading the block editor is also affected and whether this would mean separate concerns for JS intended to be used within the admin or the front end of the site.
What is your proposed solution?
I don't really have the 'right' answer, and I know there are some sort of fundamental roadblocks, but I am just throwing out ideas here...
The text was updated successfully, but these errors were encountered: