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.
(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.
$(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));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.)
jQuery was simple to use, and that's a big selling point.