WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 16 months ago

#16963 closed defect (bug) (wontfix)

wp_enqueue_script bug in ie8

Reported by: jkmassel Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: External Libraries Keywords: needs-patch
Focuses: Cc:

Description

In IE 8, if you enqueue jQuery and scriptaculous, the prototype library will be included before jQuery. Because of this, jQuery will overwrite the $ method, and even though it runs noConflict() the variable is broken for both libraries. WP should be aware of this and sort the libraries for this situation. (jQuery should be first, then prototype)

Tested on WP 3.1 in IE 8 build 8.0.7601.17514

Change History (8)

comment:1 @nacin4 years ago

wp_prototype_before_jquery() seems to indicate that the proper loading order is prototype, then jQuery.

comment:2 @jkmassel4 years ago

indeed. and that does seem logical, but that order breaks in ie8. This seems to be a somewhat common issue. Quick google search: http://stackoverflow.com/questions/2830510/jquery-noconflict-not-working-in-ie8-only

comment:3 @nacin4 years ago

Are you overriding jQuery with an earlier version?

comment:4 follow-up: @jkmassel4 years ago

No, calling wp_enqueue_script('jquery') alone should always return the latest (1.4.4 in 3.1), correct? There are no plugins or methods to change the version.

comment:5 in reply to: ↑ 4 @ramoonus4 years ago

Replying to jkmassel:

No, calling wp_enqueue_script('jquery') alone should always return the latest (1.4.4 in 3.1), correct? There are no plugins or methods to change the version.

incorrect

comment:6 @jkmassel4 years ago

Poor wording on my part. It returns nothing, but it *should* enqueue the most recent version of jQuery, unless otherwise specified or overridden?

comment:7 @dd3222 months ago

This was a known jQuery bug, which has been closed as wontfix: http://bugs.jquery.com/ticket/4365

Honestly, I'm tempted to do the same here, and/or remove our wp_prototype_before_jquery() function completely - leaving it up to developers to enqueue them in the correct orders.

comment:8 @TobiasBg16 months ago

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

The current version (at least) of jQuery is smart enough to not overwrite/restore an existing $ function, when noConflict() is used: http://jsfiddle.net/7cazt/
Loading jQuery after prototype should therefore not be a problem.

As it's possible that this does not hold the other way around, wp_prototype_before_jquery() (for reference: added in [6209] for #5067) should stay for backward compatibility, as there might be plugins that enqueue both scripts in the wrong order right now.

Note: See TracTickets for help on using tickets.