[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
Thu Apr 7 23:17:07 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:
--------------------------------------+-------------------------
Changes (by jeremyfelt):

 * keywords:  has-unit-tests has-patch commit => has-unit-tests has-patch


Comment:

 With [attachment:36392.4.patch] applied and the below snippet added—load-
 scripts is printed first, a `jQuery is not defined` error appears, the
 inline script prints, and then jQuery is included.

 {{{
 add_action( 'admin_init', 'example_enqueue' );
 function example_enqueue() {
         wp_add_inline_script( 'jquery-core', 'console.log( "howdy" );',
 'before' );
 }
 }}}

 This does not appear to be a problem in current trunk.

 [attachment:36392.5.patch] adds 2 more (currently failing) tests for
 attaching inline scripts directly to core enqueued scripts rather than
 when core scripts are dependencies. I believe this is the expected output.
 See @ocean90's [https://core.trac.wordpress.org/ticket/14853#comment:41
 comment on #14853] for background.

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


More information about the wp-trac mailing list