Opened 14 years ago
Last modified 6 years ago
#15833 new defect (bug)
Script concatenation fails to take external dependencies into account.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Script Loader | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Script concatenation places the concatenated script include first, before any scripts loaded separately. If one of the scripts in the concatenation relies on a script outside the concatenation the dependency order is ignored.
When the dependencies are all internal to the concatenation things work fine (for example script4 relies on script3):
- concat=script1,script2,script3,script4,script5
But when script3 is loaded externally, script4 will break:
- concat=script1,script2,script4,script5
- external-script3
This becomes apparent if jQuery is loaded from a non-standard location (via a plugin or the code from the Codex) in that the visual editor fails to function correctly because source:/trunk/wp-admin/js/editor.js uses jQuery (which it fails to register as a dependency, see ticket:15830, but when I fixed that locally the results were the same).
I'm working around this in Use Google Libraries by globally disabling concatenation, but it would be nice if this was fixed.
If possible, it would be nice if the loader was smart enough to do something like:
- concat=script1,script2
- external-script3
- concat=script4,script5
Or at least flagged the script with the dependency as unsafe for concatenation:
- concat=script1,script2,script5
- external-script3
- script4