[wp-trac] [WordPress Trac] #54956: [5.9] wp_block_type args - "style" and "script" are always loaded on Frontend
WordPress Trac
noreply at wordpress.org
Tue Jul 19 13:58:22 UTC 2022
#54956: [5.9] wp_block_type args - "style" and "script" are always loaded on
Frontend
-------------------------------------------------+-------------------------
Reporter: pkostadinov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Script Loader | Version: 5.9
Severity: normal | Resolution:
Keywords: has-screenshots 2nd-opinion | Focuses:
changes-requested needs-patch needs-unit- |
tests |
-------------------------------------------------+-------------------------
Changes (by pkostadinov):
* keywords: reporter-feedback =>
has-screenshots 2nd-opinion changes-requested needs-patch needs-unit-
tests
* component: Editor => Script Loader
Comment:
My suggestion is to do something about this filter
https://developer.wordpress.org/reference/hooks/should_load_separate_core_block_assets/
(it's default value is "false") :
- it's name misleads that it affects only core blocks, while it affects
custom blocks as well
- in my opinion filters should affect all types of blocks, and should not
be meant for core blocks only
- this filter name suggests it does something different that it actually
does
- if I have to name the filter based on what it does right now, it would
be called "should_load_all_registered_block_assets" - and because it's the
oposite meaning of the original filter any uses of it in the core should
be reversed (!). And it's default value should be false, since you do want
to load only required assets, not all that are registered.
- based on @hellofromTonya testing, it's possible that it affects core
blocks correctly, and it may be unintended and untested side effect that
it affects custom blocks, and that it essentially breaks the expected
behaivior. Alternatively this filter could be patched to not affect custom
blocks.
- also it would be amazing if someone manages to create unit tests that
catch exactly this issue - assets for custom blocks being loaded only when
the custom block is used on the page.
This issue is still relevant in 6.0 and 6.0.1 core versions.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54956#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list