WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 8 months ago

Last modified 8 months ago

#24132 closed enhancement (wontfix)

Add jQuery 2.0 to available scripts to enqueue

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

Description

jQuery 2.0 was released, and is a major release, more than previous ones. the 2.0 branch removes support for IE8 and down. Personally, I think it'd be best to add it alongside jQuery 1.9.x instead of outright replace. That way people who want to use the 2.0 branch can, but those who need legacy IE support still, can still use 1.9.x.

My thoughts were for a new enqueue handle of 'jquery2'.

Attachments (1)

24132.diff (244.1 KB) - added by ryanduff 12 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 ryanduff12 months ago

That could work. Would allow core to enqueue 'jquery' by default and users an option to dequeue 'jquery' and enqueue 'jquery2' if they wanted to use it on the backend (assuming, other than browser support, everything in wp-admin works with 2.0). On the front end it wouldn't matter as much other than giving the user the option to enqueue one or the other for use in the theme.

comment:2 tw211312 months ago

To clarify. This wouldn't be able to be replace jQuery in WP Admin, because of needing to support IE7+ still in the admin. However, making it available to theme/plugin developers would be beneficial for those who want it.

comment:3 ryanduff12 months ago

Yeah. Noticed that once I started digging into things. First pass patch to include jquery2 for front end use.

Probably punt this to 3.7 (I think all will agree), but I can't change/set milestones.

ryanduff12 months ago

comment:4 ryanduff12 months ago

  • Keywords has-patch added

comment:5 nacin12 months ago

I think we'll probably want to just stick with the 1.x branch in core for now. There isn't much benefit to having a script in core we're not going to use that has the same API as an existing script.

I had some conversations with jQuery core members back when 2.0 was merely a line on a roadmap, and they supported the notion 1.x would be what we'll use for the foreseeable future. I'm not sure we gain anything from bundling it. Eventually (in 2-3 years maybe) we can drop 1.x, or if the landscape hasn't changed much in the next year or so, add 2.x, possibly by using conditional comments (so we serve 1.x only for lte IE8, 2.x otherwise).

comment:6 tw211312 months ago

Not even strictly for frontend facing applications? What about those who have no need to support less than IE8 that want the lighter footprint that would be available. I know many people who advise against using something like google CDN copies of jQuery, and making available would appease that. However, not bundling it would force them to get it from somewhere else.

I fully support staying to the 1.9 branch in admin.

comment:7 knutsp12 months ago

  • Cc knut@… added

What is the downside not to add it? May themes and plugins start to bundle it for front end use? Might it be better to add it early, even if not used in core yet, than later?

I mean, we are talking about jQuery, not some nicetohave.js

And WordPress is evolving beyond a CMS, taking the role as an application framework.

comment:8 follow-up: ocean9012 months ago

  • Keywords needs-patch added; has-patch removed

Having the handle jquery2 is weird. What happens when we drop the 1.x branch? What happens on jQuery 3.x. jquery3? It's inconsistent with our current handle naming.

It's means also that we need to support both versions more or less.

Patch should also include the minified version. We doesn't add unminified versions of external scripts.

comment:9 in reply to: ↑ 8 ; follow-up: ryanduff12 months ago

Replying to ocean90:

Having the handle jquery2 is weird. What happens when we drop the 1.x branch? What happens on jQuery 3.x. jquery3? It's inconsistent with our current handle naming.

It's means also that we need to support both versions more or less.


Correct. Without handling both versions this issue is moot because I don't see WordPress supporting jQuery out of the box. How else would you propose switching between which version is enqueued if we were to enqueue both under the handle of jquery? A constant that we check on in scripts-loader.php? I think the general consensus is not to make new constants either, if all possible.


As far as handling future versions, I think using jquery2 is appropriate because it's such a huge jump. The thought was that once we finally defaulted to jQuery 2.x, we'd update the 'jquery' handle to use that and just deprecate the jquery2 handle.


Patch should also include the minified version. We doesn't add unminified versions of external scripts.


Where's jquery.min.js in core? I couldn't find it. I have no issue with adding a minified file, but I was consistent with what was there now-- an unminified version of jquery. Not to mention there are a fair number of js files included in core that aren't minified-- http://codex.wordpress.org/Function_Reference/wp_register_script#Handles_and_Their_Script_Paths_Registered_by_WordPress

comment:10 in reply to: ↑ 9 SergeyBiryukov12 months ago

Replying to ryanduff:

Where's jquery.min.js in core? I couldn't find it. I have no issue with adding a minified file, but I was consistent with what was there now-- an unminified version of jquery.

In all releases since 2.2, jquery.js is minified:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/js/jquery/jquery.js

In trunk, it's temporarily uncompressed for easier debugging: [23301], [23421].

Last edited 12 months ago by SergeyBiryukov (previous) (diff)

comment:11 tw21138 months ago

Closing.

If you wish to use it, enqueue jQuery 2.0 on your own and don't unregister the core copy of jquery to use the handle. Use a different handle for 2.0. Make sure to leave on frontend only, and out of the admin.

comment:12 tw21138 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

comment:13 sabreuse8 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.