Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created January 14, 2012 22:44
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Raynos/1613169 to your computer and use it in GitHub Desktop.
Save Raynos/1613169 to your computer and use it in GitHub Desktop.
Why you don't need jQuery

Why the jQuery Abstraction isn't needed.

(One needs some form of browser normalization so that modern features works, no-one is doubting that).

Related: jQuery library critique

Abstractions that aren't needed

Selectors

QSA works (shim=sizzle). Besides selectors are generally bad practice. Favour node traversal, gEBI, gEBTN and gEBCN. (shim=domShim)

Attributes

The DOM attribute API works. Besides one rarely touches attributes and one rarely touches innerHTML. Generally one manipulates properties

Data

properties work, weakmaps work (shim=weakmap-shim)

Deferred Object

Promises, deferreds, futures, etc aren't that useful. Favour managing callbacks and using flow control techniques.

Events

DOM2 events work (shim=domshim). You don't need anything else.

Forms

The HTML form element is more useful. Doesn't give any useful abstraction

Manipulation, Traversing

The DOM works (shim=domShim). If you want set like behaviour you can use NodeComposite

Utilities

ES5 works (shim=ES5shim)

Ajax

For simple use cases the XHR API is trivial to use. For more complex use cases you can use a library like xhr

It should be noted that there is no solid shim for XHR2 yet, including file uploads & CORS.

Todo: Write an XHR2 shim

Abstractions that are still needed

CSS, Dimensions, Offset

I havn't seen any good CSS normalization shims. One propably needs some form of abstraction to handle CSS nicely.

Todo: Write an CSSOMView shim and a CSSOM shim.

Effects

Animations, Don't know of a good CSS3 shim, so we still need a browser abstraction.

Todo: Find an elegant standards compliant polyfill / shim solution to programmatic animations.

@devinrhode2
Copy link

I couldn't agree more. Also for ajax, checkout request: SuperAgent by TJ Holowaychuk

If you want help with any of this, I am readily at your disposal.

@jcolebrand
Copy link

You keep forgetting that people have already invested time in learning jQuery, and they've already written huge apps that don't need a rewrite using jQuery.

You're fighting two things here, not just one.

Also, IE7 or lower. You don't get to make the rules we have to play by.

@Raynos
Copy link
Author

Raynos commented Mar 5, 2012

That's one of the big problems, people invest time in learning jQuery when they should be investing time into host objects.

I also don't recommend you rewrite apps to remove jQuery dependency, that's a waste of time.

As for IE6/7, ugh, I fight personal battles with those because they are a pain to shim. It's easier to just ignore them.

@jcolebrand
Copy link

Easier for you to ignore, not me, when I get paid to not ignore them ;-)

@devinrhode2
Copy link

if IE -> jQuery
else -> jQ.Mobi

@Raynos
Copy link
Author

Raynos commented Mar 5, 2012

FFFFFFFFFFFFFFFFFFFFF------

jquery mobile is the biggest turd, ever.

@devinrhode2
Copy link

Agreed, something like 62K!!
jQ.Mobi is not jquery mobile, quite the opposite of tastes, jQ.Mobi is a 'html5 mobile' re-write of jQuery that supports plugins, has a super lightweight selector support (which, for novice dev's isn't bad since they probably already understand css)

Basically it supports jQuery plugins, cuts out all the crap that causes memory leaks on mobile.

Oh, biggest point is that it's 5k, and twice as fast as jquery

@devinrhode2
Copy link

jqmobi.com

@Raynos
Copy link
Author

Raynos commented Mar 5, 2012

.... jq.mobi is also a troll

if IE -> dom shim
else -> nothing

@devinrhode2
Copy link

So true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment