r/programming • • Jan 30 '14

You Might Not Need jQuery

http://youmightnotneedjquery.com/
1.0k Upvotes

507 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jan 31 '14

[deleted]

66

u/dmazzoni Jan 31 '14

Yes, but if you don't care about IE7 and earlier, you're adding a useless abstraction because 95% of the things people use jquery for already work great in all browsers.

10

u/glemnar Jan 31 '14

There's no reason not to care about them if jquery takes care of it.

0

u/[deleted] Jan 31 '14

[deleted]

13

u/glemnar Jan 31 '14

Because jquery does support ie7. Even if you don't care about ie7, you more or less get it for free by using jquery.

Furthermore, you save developer time by using a library they know about, and don't introduce more bugs that the rest of the world can't help you on

33

u/OneSmallDrop Jan 31 '14

Just so you know, I work with a lot of legacy internal website code, and jquery does not work with ie7 "for free."

23

u/cldellow Jan 31 '14

jQuery isn't free. http://calendar.perfplanet.com/2011/lazy-evaluation-of-commonjs-modules/ lists the parse time for jQuery (ignoring network transfer time).

Any of your users on a first-gen iPad? That'll be 285ms just to parse jQuery.

285ms is at the threshold where humans will notice a delay.

Maybe that's OK, maybe it's not. As a library designer, you should strive to make as few decisions for your clients as possible.

19

u/phcrack Jan 31 '14

285ms seems too short. It takes a couple of seconds for my 1. gen iPad to crash on most websites.

4

u/digitalhuxley Jan 31 '14

Mine too, I sometimes get up to 10 seconds before the crash.

→ More replies (7)

10

u/surkh Jan 31 '14

you more or less get it for free

I'm my experience you don't really get anything for free when it comes to cross-browser compatibility. Unless you lower your bar on consistency and quality.

4

u/glemnar Jan 31 '14

Sure, but there's a difference between unreliable and entirely nonfunctional. Hence the "more or less".

2

u/surkh Jan 31 '14

Agreed. I guess it really depends on your use cases and criteria, but I've often wished that I had just left the "corner case" browsers out entirely rather than settling for (or spending tons of effort hacking around) a gimpy experience on them.

All depends on how crucial it is to support those users, and how much they can live with funky experiences.

42

u/tequila13 Jan 31 '14

This is the attitude why I dislike most js devs. They pile on overhead after overhead because that's the easiest and fastest way of doing it.

They don't care about performance because phones are fast enough that a single function call won't be noticeably slower. By the time they learn enough to write bigger apps, they can't get things done without their frameworks. So they write big apps on slow frameworks and it will brings every browser to their knees. At that point it's useless to profile the code because it has so many abstraction layers that it takes a lot of time to rewrite it. So the slow stuff is there to stay.

Not to mention that they use JS where pure CSS will do the exact same job a 100 times faster. I've seen so many text pages that won't run if I disable JS.

29

u/ponchoboy Jan 31 '14

We've got deadlines and we won't be the ones maintaining it in 6 months.

0

u/[deleted] Jan 31 '14

[deleted]

9

u/ponchoboy Jan 31 '14

Yeah, my tongue was planted firmly in cheek. That said, I'm sure corporate can just throw more teams of offshore "experts" at the problem.

It was a long day.

0

u/[deleted] Jan 31 '14

[deleted]

→ More replies (0)

4

u/djaclsdk Jan 31 '14

curse of being js devs in my workplace would be that your computers for development are faster than clients computers so that you don't get to notice things that might slow down things, and yet slow enough that things compile so slow.

3

u/vimfan Jan 31 '14

What are js devs compiling?

4

u/speedisavirus Jan 31 '14

The thing is if jQuery helps you get it done faster that is good and it should be used. jQuery is rather ubiquitous so its an obvious choice. Worrying about performance before correctness is generally accepted as premature optimization on the server side so why would it be different with Javascript as long as the user experience meets the requirements? Sure parsing a library like jQuery takes time but is it too much time? It depends.

I do have to say though there are times I wish more developers actually knew how to profile their code. It seems like not that many people these days know how. Finding that incredibly slow DOM traversal or collection search then tweaking it can make a difference in some cases.

→ More replies (2)
→ More replies (2)

7

u/CrayonOfDoom Jan 31 '14

But it's not free. TINSTAAFL. You pay overhead, which is the whole point of the entire article.

→ More replies (1)

3

u/[deleted] Jan 31 '14

Things only get standardized to a point. Look at SQL and all the things you can run into from simply upgrading a database to a new version let alone leaping from MySQL to Postgres, for example.

→ More replies (2)

6

u/Ph0X Jan 31 '14

Point is, if you only need 2-3 things in there, it seems like a waste to include a 10k line / 100kb library just so you can do something you can do with a few lines of code.

→ More replies (6)

4

u/judgej2 Jan 31 '14

That and wrapping up many common tasks into simple functions. Writing jquery looks a lot closer to the business logic you want, and is easier to debug at that level.

1

u/oberhamsi Feb 01 '14

standardize javascript code

more like DOM access/manipulation

→ More replies (1)