Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to jQuery 2.x.x. #17494

Merged
merged 2 commits into from
Oct 26, 2015
Merged

Switch to jQuery 2.x.x. #17494

merged 2 commits into from
Oct 26, 2015

Conversation

XhmikosR
Copy link
Member

@XhmikosR XhmikosR commented Sep 6, 2015

Now that we don't support IE 8 it's safe to do that.

I also fixed the inconsistent jQuery version used in some examples (1.11.1 vs 1.11.3 in others)

/CC @cvrebert @fat @mdo @hnrch02

@cvrebert
Copy link
Collaborator

cvrebert commented Sep 6, 2015

What about updating the package metadata? (bower.json etc.)

@XhmikosR
Copy link
Member Author

XhmikosR commented Sep 6, 2015

I think they already use 2 in some places but I'll keep it consistent.

@XhmikosR
Copy link
Member Author

XhmikosR commented Sep 6, 2015

Nope, bower.json has "jquery": "1.9.1 - 2" so it should be OK.

Unless you mean require 2.x as the minimum version which in that case we'll need to change the version in the error message we throw when jQuery isn't available.

@hnrch02
Copy link
Collaborator

hnrch02 commented Sep 6, 2015

👍

@XhmikosR
Copy link
Member Author

XhmikosR commented Sep 6, 2015

Cleaned the branch up a little bit.

@XhmikosR XhmikosR force-pushed the v4-dev-xmr-jquery-2.x branch 2 times, most recently from d07682e to 97f269e Compare September 8, 2015 04:11
@XhmikosR
Copy link
Member Author

So, what do we do with this? Merge it as is, or change the version in the error message we throw too?

@cvrebert
Copy link
Collaborator

Unless you mean require 2.x as the minimum version

Yeah that's what I'm suggesting, since BSv4 doesn't support IE<9 anyway.

@XhmikosR
Copy link
Member Author

All right, I'll make the changes and ping you again.

@XhmikosR XhmikosR force-pushed the v4-dev-xmr-jquery-2.x branch 2 times, most recently from b4d0f3e to ed61cf8 Compare September 19, 2015 07:52
@XhmikosR XhmikosR changed the title Switch to jQuery 2.1.4. Switch to jQuery 2.x.x. Sep 19, 2015
@cvrebert
Copy link
Collaborator

Personally, LGTM.

@mdo
Copy link
Member

mdo commented Sep 19, 2015

Up to @fat honestly.

@XhmikosR
Copy link
Member Author

Ping @fat otherwise I think we should merge it if everyone else agrees.

@cvrebert
Copy link
Collaborator

👍

XhmikosR added a commit that referenced this pull request Oct 26, 2015
@XhmikosR XhmikosR merged commit b0aa102 into v4-dev Oct 26, 2015
@XhmikosR XhmikosR deleted the v4-dev-xmr-jquery-2.x branch October 26, 2015 21:26
@danimalweb
Copy link

I know this is not Bootstraps problem but....WordPress has no plans to move to jQuery v2. Now that BS v4 depends on jQuery v2 is this going to become a problem for theme developers who want to use BS v4?

I noticed that if jQuery v2+ is not loaded we now get a console message. Can BS4 work with jQuery V1.11.X ?

@XhmikosR
Copy link
Member Author

Yes it can (after all we used 1.11.3 until now), but I guess there's no guarantee in the long term.

jQuery 2.x is out for a long time now, and honestly, we should really start ignoring ancient browsers. It's 2015, almost 2016, in an era that browsers are developing rapidly, not like 10 years ago.

Maybe the WordPress guys will reconsider for their next major version to start using jQuery 2.x by default. By then we might have jQuery 3.x anyway...

@ocean90
Copy link

ocean90 commented Oct 30, 2015

I don't quite understand why you prevent using jQuery 1.x with Bootstrap v4. The only difference is, that 2.x doesn't support IE 6-8. It's not like 2.x has a feature which is actually required by Bootstrap.

Maybe the WordPress guys will reconsider for their next major version to start using jQuery 2.x by default.

Probably not, because of the missing benefit.

@danimalweb
Copy link

Is there any chance of not making jQuery 2.x a minimum requirement for Boostrap 4?

@XhmikosR
Copy link
Member Author

Well, first of all, we shouldn't really use jQuery at all. But that is a task that requires a lot of hours and has its own drawbacks.

That being said, there is no gain for us to use 1.x since we don't support old browsers. It's simple like that. If one wants to use 1.x, they can the same way someone might use Ruby 1.9.3, or node.js 0.8 and so on. Things might work there but we don't test them thus can't support them.

Anyway, /CC @cvrebert if you have something to add.

@danimalweb
Copy link

You make some great points and from a BS perspective it makes perfect sense.

But from a theme developers point of view, with Bootstrap v4 now throwing an error if jQuery < 2 (commit 9eded91) will lead developers to unhook the WP jQuery to include v2 instead. Deregistering the WP version of jQuery is considered bad practice.

Is there some middle ground? Ship BS4 with jQuery v2, but allow v1.9.x without the error message?

@XhmikosR
Copy link
Member Author

That was my original patch if you check the comments on the top.
On Oct 30, 2015 18:16, "Daniel Hewes" notifications@github.com wrote:

You make some great points and from a BS perspective it makes perfect
sense.

But from a theme developers point of view, with Bootstrap v4 now throwing
an error if jQuery < 2 (commit 9eded91
9eded91)
will lead developers to unhook the WP jQuery to include v2 instead.
Deregistering the WP version of jQuery is considered bad practice.

Is there some middle ground? Ship BS4 with jQuery v2, but allow v1.9.x
without the error message?


Reply to this email directly or view it on GitHub
#17494 (comment).

@nextgenthemes
Copy link
Contributor

+1 For keep supporting version v1 of jQuery because its a causes nightmares if you start to replace jQuery on WordPress sites. Its rightfully highly discouraged by WP people who know what they are talking about. Considering the tons of bootstrap based themes and plugins out there this would cause a lot of pain.

Correct me if I am wrong but isn't there no difference between jQuery v1 and v2 besides that v2 has code removed that is needed for IE <= 8 ? So bootstrap4 not actually uses, and will not use any new functions because there are none. So why demand it and throw a error when there is no reason to do so?

@zacechola
Copy link

Bootstrap does not currently use any exclusively jQuery v2 features, but that is not a guarantee that it will always be that way. If your site, such as a Wordpress site, continues to require jQuery v1, then there is not currently any harm falling back to v1. Just install v1 instead of v2 and you're good to go., as @XhmikosR has previously stated.

For sites that do not have a dependency on v1, depending on v2 makes sense. It's a smaller library in large part because it removes a lot of support for older browers, browsers that are no longer supported by Bootstrap in v4.

👍 on this merge, as far as I'm concerned, but I also do think we can remove the error from Bootstrap, too. The dependency is already defined elsewhere and Bootlint might be a better place to warn Bootstrap users of the version mismatch.

@retlehs
Copy link
Contributor

retlehs commented Nov 4, 2015

any chance that this could be reverted? breaking JS for sites running jquery 1.x.x when bootstrap doesn't use anything from jquery 2 seems wrong. like others have mentioned, this is now a problem for anyone that uses wordpress.

Maybe the WordPress guys will reconsider for their next major version to start using jQuery 2.x by default.

i wouldn't count on that happening any time soon.

+1 For keep supporting version v1 of jQuery because its a causes nightmares of you start to replace jQuery on WordPress sites. Its rightfully highly discouraged by WP people who know what they are talking about. Considering the tons of bootstrap based themes and plugins out there this would cause a lot of pain.

^^^ this.

@chriscarr
Copy link

😳 Love it or hate it, a lot of us make a living with WP, and this is super bad news.

@kalenjohnson
Copy link

I don't really follow the reasoning for throwing an error. If jQuery 2.x support were necessary, then sure. But as far as I know, there aren't any new features in jQuery 2.x yet over 1.11.x

If it were possible to use new features in the future of jQuery 2, I could understand pushing this now. However, since there are no new features in jQuery 2, it seems a little premature to require it when there are no new features and we're not really sure when/if new features that Bootstrap can use will be available.

I can understand making the dependency jQuery 2, but throwing an error seems premature and unnecessary.

@mrchimp
Copy link

mrchimp commented Nov 5, 2015

If this is how it's going to be then I won't be able to use Bootstrap 4 and that would be a shame.

@kafeltz
Copy link

kafeltz commented Nov 9, 2015

I think WP themes should stick with older version of bootstrap (v2, v3) and forget v4 (which right now is not released yet). Otherwise this will stimulate them to continue jQuery 1.x.x forever.

@retlehs
Copy link
Contributor

retlehs commented Nov 9, 2015

i think WP should support jquery 2.x.x, and in the meantime we will go back to enqueueing it ourselves

no way that we are not going to use v4. been using it for a while now and it's great.

Sent from my iPhone

On Nov 9, 2015, at 7:35 AM, Ismael Santos Kafeltz notifications@github.com wrote:

I think WP themes should stick with older version of bootstrap (v2, v3) and forget v4 (which right now is not released yet). Otherwise this will stimulate them to continue jQuery 1.x.x forever.


Reply to this email directly or view it on GitHub.

@t1st3
Copy link

t1st3 commented Nov 9, 2015

While this is bad news for WordPress devs, I don't think Bootstrap's job is to comply with all WordPress rules. It's like saying to a car manufacturer that his new car sounds cool but does fit in your current parking spot. The manufacturer proposes a car "as-is" with its many options; if you want it, you'll have to adapt your parking...

@retlehs, in your Roots / Soil projects, you already deregister WordPress's "original" jQuery to replace it with the same version of jQuery, but from a CDN (see https://github.com/roots/soil/blob/4e9ad4562e1592c49f1f3a26c4dad1e00500c0c0/modules/jquery-cdn.php#L15). So basically, a WP theme developer could use the same technique to load jQuery 2 instead of jQuery 1 (as you also explain on roots.io forum, or as you mention just above).

Yet, doing that, the WP-theme developer would have to deal with situations like "my BS4/jquery2-based theme is not compatible with this or that jquery1-based plugin". Again, this announces headaches for WP devs, but I think this is out of scope for Bootstrap.

The only "solution" to this would be to lobby WordPress guys to use jQuery 2.x.x.

@retlehs
Copy link
Contributor

retlehs commented Nov 9, 2015

I don't think Bootstrap's job is to comply with all WordPress rules

yes, but the points brought up earlier in this thread are still relevant:

Bootstrap does not currently use any exclusively jQuery v2 features

there aren't any new features in jQuery 2.x yet over 1.11.x

However, since there are no new features in jQuery 2, it seems a little premature to require it when there are no new features and we're not really sure when/if new features that Bootstrap can use will be available.

I can understand making the dependency jQuery 2, but throwing an error seems premature and unnecessary.

@t1st3
Copy link

t1st3 commented Nov 9, 2015

Agreed @retlehs, throwing an error is a (maybe too) strong move. But it may make really more sense if jQuery's team puts features in 2.x.x, leaving 1.x.x without these features.

@mrchimp
Copy link

mrchimp commented Nov 9, 2015

It's like saying to a car manufacturer that his new car sounds cool but does fit in your current parking spot.

More like saying that the new work van doesn't work on the roads I deliver to. Or something. Analogies can only go so far.

Agreed @retlehs, throwing an error is a (maybe too) strong move.

This. The error "Bootstrap's JavaScript requires jQuery version 2" isn't actually true...yet.

@austinpray
Copy link

Well we should get away from analogies and focus on the bare reasoning behind this approach.

These are the arguments for using jQuery 2:

~12% lower file size.

jQuery 1.11.2 minified and gzipped: 33,321 bytes (32.54 KB).
jQuery 2.1.3 minified and gzipped: 29,562 bytes (28.87 KB).
( | 29562 - 33321 | / ((29562 + 33321)/2) ) * 100 = 11.9555% difference

Modular builds

Custom builds for even smaller files: This feature has been greatly refined and extended since its debut in jQuery 1.8. You can now exclude combinations of 12 different modules to create a custom version that is even smaller. A new minimal selector engine, basically a thin wrapper around the browser’s querySelectorAll API, lets you shrink the build to less than 10KB when minified and gzipped. See the README for instructions on how to create a custom build, and remember that any plugins you use will also need to stick to the subset you select.

This would be a really good argument but you guys aren't even using this feature.

Notably absent from the above arguments:

"jQuery might add new features"

This is not a good reason whatsoever. This is not even an argument, it's baseless speculation. jQuery 2.0 is 100% backwards compatible with 1.0 and there are no plans to change this. Why would jQuery break backwards compat after hundreds of manhours backporting fixes to 1.x? Even the roadmap for jQuery 3.0 looks tame as far as backwards compatibility.

Recommendation

There is no reason at all why an error should be thrown. Again: there are zero reasons to disallow jQuery 1.x to be used with bootstrap.

Ignoring the fact that IE8 still has an 11% market share and WordPress is used by 25% of the top 10 million Alexa ranked websites: there is simply no argument for breaking compatibilty with jQuery 1.x. jQuery 1.x and 2.x are API compatible on purpose. Why would you limit the flexibility of bootstrap arbitrarily like this?

Sauces:
http://w3techs.com/technologies/details/cm-wordpress/all/all
https://github.com/jquery/jquery/wiki/Roadmap
https://blog.jquery.com/2013/04/18/jquery-2-0-released/
https://mathiasbynens.be/demo/jquery-size
https://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0

@twbs twbs locked and limited conversation to collaborators Nov 9, 2015
@XhmikosR
Copy link
Member Author

XhmikosR commented Nov 9, 2015

@cvrebert: so, what should we do with this?

@cvrebert
Copy link
Collaborator

We're backpedaling on this; see #18267.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.