r/javascript • u/magenta_placenta • Jun 09 '16
jQuery 3.0 Final Released
https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/4
u/berlihm Jun 10 '16
Don't forget the jQuery Migrate plugin. It's useful for spotting uses of deprecated APIs. Maybe not necessary for small projects but in bigger projects where lots of separate teams depend on jQuery it can be useful.
25
u/temp1609509424 Jun 10 '16
We set out to create a slimmer, faster version of jQuery (with backwards compatibility in mind). We’ve removed all of the old IE workarounds and taken advantage of some of the more modern web APIs where it made sense.
And yet, filesize grew. Welcome to modern JS.
25
u/dixncox Jun 10 '16
File size growing doesn't imply it's more bloated. It could still be much faster. Have you looked at any performance metrics? I personally have not.
4
Jun 10 '16
Besides performance, 3.0 introduces more features, which is always going to increase filesize. I'll pay for a couple of extra bytes for all the native Promise support. Makes code so much more legible.
1
5
u/inu-no-policemen Jun 10 '16
https://mathiasbynens.be/demo/jquery-size
Scroll to the graph at the bottom. It went down quite a bit with 2.0 and only marginally increased in size since then.
Be sure to use Brotli compression whenever it's supported by the UA. It's already supported by Firefox and Chrome.
1
Jun 10 '16
Those few extra kilobytes are really gonna kill the user experience, forget the general speed enhancements and incredibly convenient features.
2
1
u/dangoodspeed Jun 10 '16
Any idea how long it should take Google to update their hosted library for version 3.0?
-1
u/Sebazzz91 Jun 10 '16
JQuery slim excludes ajax support? That's stupid, surely they could provide a small wrapper around that clunky XmlHttpRequest.
9
Jun 10 '16
The idea is you'd use jQuery slim for the jQuery object and something like fetch for AJAX calls, I believe.
-21
u/crazyeight Jun 10 '16
wtf is jQuery
9
u/DOG-ZILLA Jun 10 '16
For real? It's a library that makes manipulating the DOM a breeze with CSS style selectors and chaining. Also has a nice AJAX API amongst many other helpful features.
0
Jun 09 '16
[deleted]
5
u/Elession Jun 09 '16
Would you use Angular/Ember/React when you just want to have some little interactions? Not everything is an app, webpages still exist.
1
u/bel9708 Jun 09 '16
Why would you import a library at all if you just need to do some little interactions?
3
2
u/Elession Jun 09 '16
Sometimes you won't need it if it's really basic (and most of my static websites don't have any libraries at all) but if I want a bit more (but still a webpage) I'm not going to spend time rewriting existing libraries for fun.
It might be some vanilla js lib, it might a jquery plugin but it's very far from being a binary no-lib/framework-only choice.
6
5
u/Ob101010 Jun 09 '16
This kind of thinking overlooks the huge demand still for things like wordpress sites. Not everything is a single page app that needs real time 2 way communication or node or nosql. Huge numbers of traditional sites still being developed. jQuery and things like wordpress (or joomla, or drupal) work very well together. Therefore, theres still tons of reasons jQuery is still important.
0
Jun 10 '16
[deleted]
1
u/Ob101010 Jun 10 '16
Your point was that you dont need it.
Cause mine was that huge numbers do use it.
0
Jun 09 '16
[deleted]
1
u/2Punx2Furious Jun 09 '16
bind your model and your view so that when your model changes, the view reflects those changes automatically
handle routing
Could you please expland on these a bit more? I did the Angular course on codecademy, but at the end of it I was very confused.
What's model and view? What is routing?
16
u/snarkyturtle Jun 09 '16
With jQuery, updating something would be akin to doing something like:
$('.content').text('Content')this is well and dandy until you have a ton of fields to update
$('.firstname').text('John') $('.lastname').text('Doe') $('.address').text('123 Fake St') $('.phone').text('1231231234')What MV* solutions allow you to do is declare a model in a .js file and use binding to do what all the $.text calls would do:
// main.js $scope.person = { firstname: 'John', lastname: 'Doe', address: '123 Fake St', phone: 1231234 } // index.html <div> <p> {{person.firstname}} </p> <p> {{person.lastname}} </p> <p> {{person.address}} </p> <p> {{person.phone}} </p> </div>Now the best part is that you're probably fetching this from the database so you could just fetch json from the server and pass that to the model like so:
// main.js $.getJSON('/person/find/1').then(function(person) { $scope.person = person })The best part of using the Model View paradigm is that you can add models/fields with minimal changes to the code. Just add that to your backend and your view and you're good to go.
2
1
u/2Punx2Furious Jun 09 '16 edited Jun 09 '16
Oh, I see, it looks very useful. Is that Ember or Angular?
It kind of reminds me of other Object Oriented programming languages.
4
3
Jun 10 '16
[removed] — view removed comment
4
u/azium Jun 10 '16
It doesn't have to be OOP though.. you can achieve model -> view bindings in a purely functional world.
4
u/vinnl Jun 10 '16
In fact, that's what React largely does. It doesn't feel similar to Angular at all...
1
u/2Punx2Furious Jun 10 '16
Which one do you recommend to start with? I started with Angular, but I didn't like it very much.
2
4
u/moustachedelait Jun 09 '16
Think of a registration form. The view is the input boxes that you see. The model is where the data lives that you fill into that form. The router is how a single page webapp figures out when you show you the registration form and when to show you something else
1
u/2Punx2Furious Jun 09 '16
Oh, this helps a lot, thanks!
3
u/moustachedelait Jun 09 '16
if you'd like, check out backbone.js, it also deals with those concepts and studying it or a course on it, might just let those things sink in a deeper. Repetition is the mother of science!
2
u/antibody339 Jun 09 '16
Oh god... No offense, but why are you studying Backbone? It was a very ... less than magical experience for me. React is the way to go.
2
u/moustachedelait Jun 10 '16
I'm not studying it, but just suggesting it. I use it for work and enjoy it, and I think it can be valuable to learn models and views through
0
0
Jun 10 '16
[deleted]
0
Jun 10 '16
[deleted]
1
u/RiskyShift Jun 10 '16
On the other hand: jQuery is pretty big, you probably don't need a significant chunk of its features (even the "slim" build is a lot of code) and for the ones you do actually need there's probably a much smaller and more focused library.
0
Jun 09 '16
[deleted]
46
u/xbudex Jun 09 '16
Messy workarounds is the reason to use jQuery. All browsers have bugs with the DOM and with jQuery I don't need to worry about them.
1
Jun 10 '16
is this still a problem with modern web browsers? I mean back in the IE6 days yeah but what problems do modern browsers have?
10
u/xbudex Jun 10 '16
Yes, there is a list of browser bugs fixed by jQuery excluding IE. I went looking for the list but couldn't find it. Most of the issues are with mobile browsers, but Chrome and Firefox still had a good amount. jQuery isn't a must like it was in the IE6 days, but browsers do still have bugs and jQuery will fix those bugs.
11
u/webdevpassion Jun 09 '16
Can you give examples of messy workarounds? Or is this just a jab at at useful library because it isn't the trendiest thing?
0
-1
31
u/[deleted] Jun 09 '16
"jQuery.Deferred is now Promises/A+ compatible"
well, shit