(no title)
mddw | 13 years ago
Been there, done that. And it's a pain in the *
You'll find yourself needing a method to add or remove classes eficiently. So you'll rewrite .addClass() and .removeClass()
Then you'll need a clean way to make Ajax and callbacks. You'll rewrite .ajax() and .when()
Then you'll need to fade something in all browser. So you'll rewrite .animate()
Ad lib.
JQuery Minified and GZipped is 35k (not 90 as the op said, ignoring the gziping.) JQuery is cached in most browsers. The performance hit is not worth the pain of re-inventing the wheel.
The problem is not JQuery, it's bad code. Bad code won't magically disappear in vanilla JS.
gildas|13 years ago
You don't need to rewrite it, cf. this shim [1] for example.
> Then you'll need a clean way to make Ajax and callbacks. You'll rewrite .ajax() and .when()
They are plenty of good Ajax implementations, for example this one [2]. If you need promises, there are good libraries too [3].
> Then you'll need to fade something in all browser. So you'll rewrite .animate()
Applying a fading effect on an element shouldn't be a mandatory feature. You can just use CSS3.
[1] https://developer.mozilla.org/en-US/docs/DOM/element.classLi...
[2] http://jibbering.com/2002/4/httprequest.html
[3] https://github.com/kriskowal/q
nasmorn|13 years ago
TazeTSchnitzel|13 years ago
Or, you'll use element.classList.add()
>You'll rewrite .ajax() and .when()
XHR isn't really too verbose.
>So you'll rewrite .animate()
Or you'll do elem.style.transition = ... and use elem.addEventListener;
Really, the plain DOM isn't that bad. If you make one or two sugar methods, they'll be far, far, far smaller than jQuery, and probably far faster.
mddw|13 years ago
What's the point to use shims or polyfills if it means including some others libraries ?
JQuery is not slow. If you .addClass() two hundred divs, sure. But for basic DOM manipulations, it's fine.
JQuery is not heavy. 32kb. It may be in cache. You'll likely gain that twice 32kb by optimizing your png.
This anti-JQuery war is a silly fad started by people who don't make websites.
And as per arguments like "a fadein should not be mandatory blablabla", explain it to the client. It may work. Or it may not.
Finster|13 years ago
neya|13 years ago