[wp-trac] [WordPress Trac] #50328: Enqueue script and style assets only for blocks present on the page
WordPress Trac
noreply at wordpress.org
Fri Jul 3 11:18:06 UTC 2020
#50328: Enqueue script and style assets only for blocks present on the page
-------------------------+-------------------------
Reporter: aduth | Owner: gziolo
Type: enhancement | Status: assigned
Priority: normal | Milestone: 5.5
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: | Focuses: javascript
-------------------------+-------------------------
Comment (by mcsf):
Catching up on this ticket and taking a new look at
[https://github.com/WordPress/gutenberg/pull/22754 Gutenberg PR 22754], it
seems to me that we are risking a lot more bugs and breakage by switching
from plain enqueueing to inline printing.
The original approach has been more thoroughly tested and, while flashes
of unstyled content are something to avoid, they seem to be ''a better
problem to have'', one that can be mitigated elsewhere, and one especially
mitigated by caching.
> Maybe themes are just `_doing_it_wrong` by targeting `.entry-content >
*` with display properties and this should be fixed with education.
I think this is the wrong way to look at it. Even when there are clear
directives (e.g. deprecation of a set of private HTML classes) there are
always issues of breakage because those directives were ignored. I can
imagine a much messier situation if we retroactively burden themes with
staying away from particular ways of styling `.entry-content`. It would be
destructive for both existing sites and the block editor.
----
This question reminds me of how JS projects under webpack can be "tree-
shaken" when modules are clear about whether they
[https://github.com/WordPress/gutenberg/pull/17945 are "pure"] or have
side effects. Down the line (or sooner if the Beta period reveals this to
be a more pressing issue), I can imagine a similar affordance in the
block-rendering stack where admins can choose whether they prefer their
dependencies inlined.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50328#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list