[wp-trac] [WordPress Trac] #36392: wp_add_inline_script() breaks script dependency order when using script loader (no SCRIPT_DEBUG)
WordPress Trac
noreply at wordpress.org
Fri Apr 8 17:36:14 UTC 2016
#36392: wp_add_inline_script() breaks script dependency order when using script
loader (no SCRIPT_DEBUG)
--------------------------------------+-------------------------
Reporter: westonruter | Owner: swissspidy
Type: defect (bug) | Status: assigned
Priority: high | Milestone: 4.5
Component: Script Loader | Version: trunk
Severity: major | Resolution:
Keywords: has-unit-tests has-patch | Focuses:
--------------------------------------+-------------------------
Comment (by azaozz):
As far as I understand this, we cannot guarantee outputting a script right
before or right after an enqueued script (that has dependencies) if we
concatenate scripts. Example:
- Add "before" and "after" scripts on `jquery-ui-mouse`.
- Enqueue `jquery-ui-dialog` which depends on `jquery-ui-draggable` which
depends on `jquery-ui-mouse`.
All of these scripts are concatenated by default. How is concatenating
supposed to work in this case? The only way I see is to "break" the
concatenation and take them and all their dependencies out, which seems to
be what we are trying to do now.
If the "before" and "after" scripts do not have to be right before and
right after, this can be achieved in couple of different ways.
`$wp_scripts->localize()` works that way, or scripts can be outputted
directly on the same hook with lower or higher priority. Then they will be
before or after all other scripts.
If we *must* have "right before" and right after" scripts, thinking the
only "sane" way would be to disable concatenating when they are used.
Also, looking forward to the time we stop concatenating scripts and
stylesheets because of HTTP/2 :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36392#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list