I hate Javascript, but I love JQuery

By admin - Last updated: Tuesday, April 29, 2008 - Save & Share - One Comment

When it comes to the web, I prefer to stay on the server, where it’s safe. I love the stability of the environment I get in server side code, and I detest the client side chaos that goes on in the faggotry of browser wars and their incompatibilities and differences.

If I can, I try to avoid scripting completely. In the current state of browser affairs, I don’t feel like I can rely on Javascript for anything more than decoration and minor UI enhancements. When I do have to work with Javascript (and by that I mean any client side scripting language), I do it in a very conservative, “1.0″ way.

This post explains my feelings well, and even goes as far as to propose the term “JUE”, for “Javascript Usability Enhancement”:

AJAX [Javascript on the whole], should only be implemented after the page has complete functionality, and should only be used to enhance the usability of the webpage. Every function which is possible through the AJAX, should also be possible in the same or similar way without the AJAX (but usually with an extra page-load or two).

This isn’t just about usabilty, unobtrusiveness, or separation of code though. There are plenty of advantages on starting from the server side and working your way up. Some of my favorites are…

But despite all that, scripting does help address the very real, and always increasing need for rich interfaces on the web. If used right, scripting can have great results for a lot of people.

The real reason why I don’t like client side scripting is because Javascript, and the way it’s designed, doesn’t make it easy to do anything worthwhile. Take the fact that it’s modeled as a low level interface for document manipulation, add the problems that come from browser inconsistencies, top it off with poor debugging and IDE support, and you got yourself a clusterfuck that can be only beaten by the current state of CSS. Every time I pick up Javascript, it’s a productivity struggle of monumental proportions.

Javascript is like the C++ of web programming: very flexible, but too low level to be adequately productive. So the solution is not to use it at its lowest level, just like I don’t use Win32 in my apps when I want to get things done. It turns out that there are tons of great libraries that already implement all of those things that you would have to do over and over again in Javascript.

I suppose I should have thought of it before, that maybe a million people have already done this a million times before, and maybe some of those people put it together in a way that takes away the need for me to do for the millionth-first time. I guess I just never saw Javascript as a serious enough language to make “libraries” for. Back when I started, Javascript “libraries” were the things you copypaste from Javascripts.com to make gay rainbows on your text.

The problem is, every time I tried to research Javascript or AJAX, I always find tons of resources, merrily spewing forth explanations on how to use document.getElementById(), make XMLHttpRequests, or animate things using setTimeout and setInterval, and enumerating the myriads of caveats and their workarounds between browsers. Not once I’ve seen a site stop, and tell me “Hey, you! You’re doing stuff that’s already been done a million times! Why not just use a library that handles all of this for you?”

Point in case, I was recently asked to do a small widget that cycles images, “like the thing on Yahoo Movies. After several hours of browsing sites that explained in great detail all the pages of code I would have to do, and tons of custom implementations of said code that did almost kinda what I wanted, I came across JQuery. And it felt like God almighty came down in an angelic choir, and slapped the Truth into my face with a tire iron. I was enlightened.

JQuery delivered an excelent first impression. Having had no previous experience with it whatsoever, it took me 10 minutes, and a grand total of two lines of code to make my animated scroller. It already had everything done for me, starting from a CSS-like element finder syntax, to automatic tweening of any value. I don’t usually enjoy adding non-standard, external libraries to my code, but this one of those things that really should be standard, and only isn’t because all the other JS toolkits would cry their eyes out.

It seems Javascript coders suffer a lot from the “Not Invented Here” syndrome. Maybe it’s because you don’t need anything but a browser to write Javascript. Maybe watching your page come to life after all of that hard work is very satisfying. Maybe they’re afraid that if someone looks at their code and sees them use a library, they won’t seem as hardcore. Or maybe someone just needs to clean up the internet of all of the feces that the last generation of Javascripters left behind.

I, however, don’t have the patience for it. From now on, I’ll just be dropping JQuery into all of my projects.

Posted in Web • Tags: , , Top Of Page

One Response to “I hate Javascript, but I love JQuery”

Comment from Richard
Time November 24, 2009 at 12:54 pm

I too love jQuery. It makes JavaScript development enjoyable. I actually get depressed having to deal with DOM elements in C# and Java because I wish I could just “jQuery it”.

Write a comment

Currently you have JavaScript disabled. In order to post comments, please make sure JavaScript and Cookies are enabled, and reload the page. Click here for instructions on how to enable JavaScript in your browser.