Tuesday, 24 February 2015

Life beyond JQuery...

I knocked up a little project the other day (here) and threw it up onto GitHub but the first response I got from anyone was "Why didn't you do it in JQuery?"

* To keep the size down

In the best of all possible worlds you can get JQuery down to 28k, the simple minified version however is closer to 84k, for the functionality I actually wanted to include this was way over the top and I didn't need any other functionality that would drive me to include it.
Also, while my code would have been smaller had I used JQuery it would not have been that much smaller - mainly because I wanted some very specific behaviours.

* To reduce complexity

Every additional file you need to add into a project is one more thing the user of your code needs to keep track of, it sounds silly but I've handled more than my share of support requests from people who never bothered to check dependencies. 

* To make it load independent

When trying to optimised you code for speed it becomes a pain when you need to block rendering in order to make sure your JS files load in the order you expect and the order they require simply so you wont get any errors. 

* Because I didn't need it

In all honesty the syntax difference between using the JQuery element selector and doing it manually is tiny. If you've been programming JQuery since you started then you might find it difficult, but if you know how JQuery does things, it's actually not that hard to do without it. 

Really the last answer is the only I need. There was no reason for me to use JQuery, no functionality that could not be easily done without it and no issue of cross browser compatibility that could not be solved with some very simple code.

I'm not a purist. I use JQuery all the time in various project but sometimes it's the proverbial sledgehammer to crack a walnut. People need to remember that JQuery is a library that extends the DOM not a default upgrade to all browsers.

No comments:

Post a Comment