Is jQuery still relevant? (2014)
syntaxsuccess.com
syntaxsuccess.com
(and my usual disclaimer - if you're going to use React for a quick project, you can probably use Preact and save the extra bloat)
React completely removes the need for jQuery if you're using it correctly, because you should rarely if ever touch the DOM, and jQuery is... a DOM manipulation library.
https://github.com/github/fetch/blob/master/package.json
And a Promises library with zero dependencies:
https://github.com/stefanpenner/es6-promise/blob/master/pack...
This is not as difficult as you're making it out to be.
jQuery was simple to use, and that's a big selling point.
Personally, if I'm working on a project that isn't big enough to warrant a framework, I'm probably not concerned about Internet Explorer either. (And even then my understanding is that IE isn't even that bad these days.)
I think I'd probably agree with you on the "ship it ASAP" premise, but Vue could be a real contender in that category as well.
$(window).on('scroll', function() {
if ($('.some-class-matching-one-element-in-a-tree-of-one-hundred-thousand').offset().top > $(window).scrollTop()) {
$('.some-class-matching-one-element-in-a-tree-of-one-hundred-thousand').on('click', function() {
if ($(this).closest('.some-other-random-class').hasClass('selected')) {
$(this).closest('.some-other-random-class').addClass('.blue-background');
$('.some-class-matching-one-element-in-a-tree-of-one-hundred-thousand').removeClass('selected');
}
}
}
});
Then when you have terrible mobile performance you just tell the stakeholders that if they want good performance they need to pay you more to then make a native app.jQuery(which was really sizzle) was a plague because it allowed garbage developers to search the entire DOM over and over and over again(aka get shit done bro). This would clobber the performance in mobile devices because JavaScript is single threaded and lead to the idea that JavaScript itself was unsuited for mobile applications.
Sorry, its garbage for anything but spicing up a WordPress site.
Bad program is possible in all framework. One can write a slow React app as well.
The constant traversing of the DOM over and over and over again to re-select jQuery DOM objects. Sure you can write that correctly. But I rarely if ever saw anyone to the point that when I would, most developers who typically worked in jQuery would be confused.
The proper thing to do would be to select that element before the scroll and pass that into the event. Otherwise performance would still be awful.
Obviously that is just a toy example that doesn't really have a point(like you correctly stated), but it was to illustrate the constant riding of sizzle to select things over and over again, killing performance.
EDIT: Downvotes prove the point. Take a look at the sizzle cache for yourself. The fact that so many people misunderstand jQuery enough for this to get significantly downvoted on a site where the average competency of developer is probably a bit higher than in the wild shows you exactly the horror that jQuery was for mobile performance.
Although, maybe that means there really aren't many skilled web developers on this site anyway. Because the people who downvoted this are completely wrong so maybe I shouldn't assume there is much talent around here.
(function(window, $) {
var $some = $(.some-class-matching-one-element-in-a-tree-of-one-hundred-thousand');
if ($some.length < 1) {
return;
}
var $closest = $some.closest('.some-other-random-class');
if ($closet.length < 1) {
return;
}
var $window = $(window);
$window.on('scroll.foo', $.throttle(function() {
if ($some.offset().top > $window.scrollTop()) {
$window.off('scroll.foo');
$some.on('click.foo', function() {
if ($closest.is('[chosen]')) {
$closest.addClass('blue');
$some.removeAttr('chosen');
}
});
}
}));
}(window, jQuery));For the two dozen or so various medium/large sites i've worked on; Jquery, underscore and d3 give me everything I want and then some.
But it's certainly not the "cool" kid anymore. It's an important fundamental that you can use to do a lot with - but sites with more heavy use of JS will probably gravitate towards a more structured framework like angular
https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0Rlh...
http://caniuse.com/usage-table
Many of the examples in that doc are Android < 4.1 (0.06%), IE < 9 (0.48%), Firefox < 24 (~0.1%), etc. Even IE 9-11 is only 4% of the market these days.
The browser-compatibility story is dramatically different from when JQuery was created in 2006. All of the major browsers have been auto-updating for several years now.
jQuery is less necessary than it used to be in order to get reasonable tools for working with the DOM and other browser APIs... but then again, depending on your need for marginal utility and tolerance for personal attention to corner cases, you never really needed it. If you were determined, you could always custom code a micro library that covered most of the overlap between what jQuery did and what your app needed. It's just that it often gave you the gift of not having to pay attention to those cases. It still can.
Things jQuery will always be relevant for: an example.
It might be the single most thoughtful yet pragmatic abstraction that I've had the pleasure of regularly working with in the last decade. The basic idea of using selectors to navigate the DOM was a key jump in productivity, the fluent-chained interface was thoughtful and a massive boost. It almost never leaked -- I can count on one hand the number of times in 10 years something weird was going on underneath the hood that I had to pay attention to (Angular exceeded this measure inside of a few months). And strangely enough, every other library that was its contemporary when it was born seemed to think that the problem with front-end development was JavaScript's lack of classes & traditional OO, if the amount of library that was focused on adding them was any indication. jQuery recognized how much of the pain was really coming from bad browser APIs, and how much productivity could come from building better ones, combined with idioms/concepts from the functional side.
An interesting indicative stat would be number of installs of the very latest jQuery versions.
When we do start building more complex web apps, we decided on Ember since it uses Handlebars as its templating engine.
Superdom https://superdom.site/
Not sure how relevant this is either. React barely differentiates between view and code, opting to put everything in one place.