[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
Sat Apr 9 08:48:50 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 needs-patch  |     Focuses:
----------------------------------------+-------------------------

Comment (by azaozz):

 Think I figured it out. To be able to control when scripts tags are
 printed we would need to append all tags (strings) to another var inside
 $wp_scripts including the tag(s) with the concatenated scripts.

 Currently we are echoing these tags directly from $wp_scripts::do_item(),
 but "holding" the scripts that can be concatenated to the very end. That's
 why any script that has "before" or "after" is always printed above the
 concatenated scripts.

 Making new var to hold all script tags until the end (instead of echoing)
 seems straightforward, but thinking even a small risk of introducing
 regressions it too much at this point.

 In 36392.7.patch: when concatenating scripts if "before" or "after" is
 set, stop concatenating and output all already processed scripts right
 away. This basically turns off concatenating when a plugin sets "before"
 or "after" on a core script.

 The tests need fixing since now we echo from do_item() (getting too late
 here, will look tomorrow).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36392#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list