Live data from Hacker News

You might not need jQuery

youmightnotneedjquery.com

221–230 of 360 posts

Re: You might not need jQuery

#222

Earlier quoted context omitted.

I believe the point is that many libraries use about 1% of jQuery. That hardly justifies pulling in the entire thing. A personal anecdote: I recently un-jQueried a little piece of code and ended up with only a couple lines of extra code. Certain parts of jQuery are heavenly and well worth it, but really basic usage doesn't actually save that much. $("#something") instead of document.getElementById("something") is not…

> I believe the point is that many libraries use about 1% of jQuery. That hardly justifies pulling in the entire thing. Sure, but if you use a few libraries that all use a couple features of jQuery you still only need to load jQuery one time and everything just works. You may not care if it only works on the most modern browsers, but someone who uses your library probably will.

Or you need jQuery two times because one of the plugins you need is not well maintained and depends on an older version. This actually happens.

Re: You might not need jQuery

#223

Earlier quoted context omitted.

I believe the point is that many libraries use about 1% of jQuery. That hardly justifies pulling in the entire thing. A personal anecdote: I recently un-jQueried a little piece of code and ended up with only a couple lines of extra code. Certain parts of jQuery are heavenly and well worth it, but really basic usage doesn't actually save that much. $("#something") instead of document.getElementById("something") is not…

It might be the most cached file on the internet. Pulling jQuery is hardly expensive. Especially if you're pulling it from the google cdn.

caching won't help for libraries that want to have a particular version of jquery baked in ...

Re: You might not need jQuery

#224
post #57

No, please no. If size is an issue for some reason or you want to have no dependencies you can use something like http://zeptojs.com/ and just embed everything in one minified file. If you do things right only the functions you are actually using will get placed in there as well. Do not reinvent the wheel to solve problems that can't be solved in much cleaner and nicer ways. Managing dependencies can be annoying, but…

I believe the point is that many libraries use about 1% of jQuery. That hardly justifies pulling in the entire thing. A personal anecdote: I recently un-jQueried a little piece of code and ended up with only a couple lines of extra code. Certain parts of jQuery are heavenly and well worth it, but really basic usage doesn't actually save that much. $("#something") instead of document.getElementById("something") is not…

So why not break up a large library into smaller useful pieces. Why can't we import only what we need.

Re: You might not need jQuery

#225

I use jQuery because the DOM API for javascript sucks, and writing jQuery is fun. You're average web app perhaps doesn't need the latest Ruby/Python/PHP framework, or perhaps it you can write it without the framework. Or perhaps you can a compiled as opposed to interpreted language because that would be faster. OR maybe you can use something that is even faster, like perhaps Assembler! Fuck it write machine code if s…

I use jQuery because the DOM API for javascript sucks, and writing jQuery is fun.

How many lines of code are actually needed to give you selectors and the most common DOM manipulations?

How many lines of code are in jQuery?

Is there anything which would not be in selectors + common manipulations that you need, and which only jQuery can provide?

Re: You might not need jQuery

#227
post #183

Earlier quoted context omitted.

Nope. jQuery 2 just removed code for IE 6/7/8. Nothing was added. Code sized reduced, but almost the same performance. My benchmark shows only 10-15% improvement. That's nothing compared to using the DOM API straight up.

Care to substantiate your benchmark where you compare jQ1, jQ2, and the native DOM API?

Here is the mentioned pull request: https://github.com/jashkenas/backbone/pull/2959

Here is his benchmark: http://jsperf.com/backbone-patch-22be8f9/2

It only compares jQuery 1 and the DOM API, no jQuery 2.

    TestBaseView: DOM API
    TestPaulView: Reduced jQuery usage
    TestView: jQuery

Re: You might not need jQuery

#228
post #57

No, please no. If size is an issue for some reason or you want to have no dependencies you can use something like http://zeptojs.com/ and just embed everything in one minified file. If you do things right only the functions you are actually using will get placed in there as well. Do not reinvent the wheel to solve problems that can't be solved in much cleaner and nicer ways. Managing dependencies can be annoying, but…

did you write this post with a thesaurus? No? You literally typed EVERY SINGLE WORD in this post?

Having tools at your disposal is a good thing. Why would you type out four sentences when you can have pages of pre-written content?

Re: You might not need jQuery

#229

Earlier quoted context omitted.

I believe the point is that many libraries use about 1% of jQuery. That hardly justifies pulling in the entire thing. A personal anecdote: I recently un-jQueried a little piece of code and ended up with only a couple lines of extra code. Certain parts of jQuery are heavenly and well worth it, but really basic usage doesn't actually save that much. $("#something") instead of document.getElementById("something") is not…

So why not break up a large library into smaller useful pieces. Why can't we import only what we need.

You can create a custom build of jQuery and exclude specific modules: https://github.com/jquery/jquery#modules.
Post reply on HN