JavaScript – Does jQuery Make Sense in Modern WebKit-Only Applications?

ecmascriptjavascriptjquery

I'm lately working on a few mobile web apps for Android (2.3+) and iOS (4+). Their browsers support most of ECMAScript5, which is very powerful, and I wanted to use language features where possible, resorting to jQuery only when I had to.

Turns out the only thing I use jQuery for is to have a shorter alternative for document.querySelectorAll. Might as well get rid of it.

If I only have to support modern WebKit browsers, is it a good idea to get rid of jQuery (and other general-purpose libraries)? They are a layer of indirection, after all.

(The apps don't have to make AJAX calls so far, I guess that's one thing that's going to get ugly. But is it worth keeping jQuery just for that?)

Best Answer

No, it doesn't make sense.

jQuery is a bloated library. Everybody knows that. And everybody uses it because it's one the rare cross-browser libraries out there that just work (note that I didn't say framework).

If you don't need support for legacy browsers, you don't need jQuery.

Small needs such as QSA shortcut or an XHR helper are thin. They are easily added through such objects.

Then, if you like its API, go for it. But it's not needed.

I can understand that some people prefer:

$( '.table' ).addClass( 'active' );

To (using By):

[].forEach.call( By.qsa( '.table' ), function( table ) {
    table.classList.add( 'active' );
} );

I find the second way more explicit, other will disagree. It's a matter of preference.

Also, if your code has any chance of being ported to legacy browsers later (or other non-webkit/sucky mobile browsers), use jQuery. It will reduce your headache later.

Related: https://softwareengineering.stackexchange.com/a/148536/42132