[wp-trac] [WordPress Trac] #25277: WP_scripts does not allow to add data after the enque has been added to HTML

WordPress Trac noreply at wordpress.org
Wed Jan 7 19:18:39 UTC 2015


#25277: WP_scripts does not allow to add data after the enque has been added to
HTML
-----------------------------------+-----------------------------
 Reporter:  hakre                  |       Owner:  wonderboymusic
     Type:  feature request        |      Status:  reopened
 Priority:  normal                 |   Milestone:  4.2
Component:  Script Loader          |     Version:  3.6
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+-----------------------------
Changes (by azaozz):

 * keywords:  has-patch => has-patch 2nd-opinion


Comment:

 > I am not married to this, a revert would not hurt my feelings.

 I'm leaning towards reverting as this may be more confusing than it's
 worth.

 The "before" is handy for providing data needed for the script so we can
 initialize it as soon as loaded. Good thing is that data can be outputted
 at any place before the <script> tag.

 This part:
 {{{
 <script>
 new API( settings );
 </script>
 }}}
 is pretty much always handled from the JS that would use that `API`.

 The only two cases where "after" may be useful would be:
 - For the `jQuery.noConflict()`.
 - "Duck punching" that `API`. Very undesirable.

 In both cases it is crucial for the "after" to be immediately after the
 <script> tag. However when concatenating the default scripts, we cannot
 add in inside the blob. The reason is WP doesn't run when outputting
 concatenated scripts and styles, or it would have to run three times on
 every page load (load-scripts.php and load-styles.php use script-loader as
 a whitelist only). So if a plugin adds/removes/changes the "after", we
 cannot catch that.

 In that terms I don't think we need to have this functionality for
 scripts. On the other hand this is useful for styles, and the placement
 there is not that critical.

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


More information about the wp-trac mailing list