Opened 17 years ago
Closed 17 years ago
#5003 closed enhancement (fixed)
WP_Scripts::print_scripts() is overly complicated
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | normal | Version: | 2.2.3 |
Component: | General | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
WP_Scripts::print_scripts() calls two recursive functions.
- WP_Scripts::all_deps() builds a hierarchical array of dependencies.
- 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 (1)
Change History (6)
Note: See
TracTickets for help on using
tickets.
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.