WordPress.org

Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#22830 closed defect (bug) (invalid)

script-loader.php Does not respect dependancies

Reported by: pathawks Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

I am trying to load an external version of jQuery (because of reasons), but unless I disable CONCATENATE_SCRIPTS, script-loader.php will load everything that depends on jQuery, and then jQuery will be loaded in the next line.
This obviously breaks everything that depends on jQuery.

To register my custom library, I am calling the following:

wp_deregister_style( 'jquery' );
wp_register_style( 'jquery', 'http://example.com/jquery.js', array(), '1.8.3' );

This results in the output:

<script type='text/javascript' src='/wp-admin/load-scripts.php?…'></script>
<script type='text/javascript' src='http://example.com/jquery.js'></script>

I don't see any reason why this shouldn't work.

Change History (4)

comment:1 nacin17 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

"Because of reasons"?

There is no valid reason to override jQuery in the admin. The WordPress admin will only ever be written for the version it ships with (which will almost always be the latest version of jQuery).

comment:2 pathawks17 months ago

I want to load it from a CDN.
It's the same version that WordPress ships with, I made sure of that.

comment:3 nacin17 months ago

I want to load it from a CDN.

Do that on the frontend. Avoid touching it in the admin. It may be the same version that WordPress ships with, but you break concatenation of default scripts this way, not to mention the issue of the CDN missing a jQuery noConflict call.

comment:4 azaozz17 months ago

+1 to what @nacin said. There's little to be gained by loading external jQuery in the admin and many things can go wrong.

For the record: this can be achieved if jQuery (or any script) is unregistered and then registered with the new location as the first thing after the WP_Scripts class is instantiated.

Version 0, edited 17 months ago by azaozz (next)
Note: See TracTickets for help on using tickets.