Ticket #5003 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

WP_Scripts::print_scripts() is overly complicated

Reported by: mdawaffe Assigned to: mdawaffe
Priority: normal Milestone: 2.3
Component: General Version: 2.2.3
Severity: normal Keywords: has-patch needs-testing
Cc:

Description

WP_Scripts::print_scripts() calls two recursive functions.

  1. WP_Scripts::all_deps() builds a hierarchical array of dependencies.
  2. WP_Scripts::_print_scripts() reads that hierarchical array and echoes out a correctly ordered list of script tags.

The function should instead call one recursive function that builds a correctly ordered array of scripts. That simple array can then be processed non-recursively.

The attached also adds a new filter, print_scripts_array that could be used to do final post-processing of the scripts to deal with things WP_Script's naive dependency system can't do. Example: if prototype and jQuery are loaded on the same page, prototype should come first.

It could use some testing.

Attachments

5003.diff (4.1 kB) - added by mdawaffe on 09/19/07 00:44:40.
replaced bad attachment

Change History

09/19/07 00:43:29 changed by mdawaffe

  • owner changed from anonymous to mdawaffe.
  • status changed from new to assigned.

It'd be nice if this could make it into 2.3 since jQuery 1.1.4 deals with the $ v. jQuery via noConflict() situation slightly differently than 1.1.3 does. This difference makes the above example (including prototype before jQuery) more urgent.

It's not strictly necessary for 2.3, though, since plugins and core can ensure prototype is loaded before jQuery by adjusting hook priorities.

09/19/07 00:43:41 changed by mdawaffe

  • keywords set to has-patch needs-testing.

09/19/07 00:44:40 changed by mdawaffe

  • attachment 5003.diff added.

replaced bad attachment

09/19/07 00:50:40 changed by ryan

  • milestone changed from 2.4 to 2.3.

09/19/07 00:50:55 changed by ryan

We can give it a try in RC1 and see how it handles.

09/19/07 00:51:21 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [6133]) Script loader cleanup from mdawaffe. fixes #5003