garann means > totes profesh

a defunct web development blog

too much jquery.. ?

Mon, 31 Jan 2011 02:28:54 +0000

This weekend I tried to take part in a virtual MDN documentation sprint. I say tried because, while I was present in IRC for some part of it and submitted some updates, I don't think I got a lot done. I changed a couple things that had been bugging me about the Rich-Text Editing in Mozilla page, but it turns out that more accurate information had existed the whole time on a different page, so that didn't really add a lot. Having finished that one little thing and feeling not very helpful, I went in search of something else to do and saw an item on the sprint wishlist about updating the Getting Started with AJAX page. I was like, "Sweet, this is easy stuff, I can do that!"

HA.

I cannot, as it turns out, do that. Not without many hours of research. I used to be able to do that, but now I do this: $.ajax(...); I do it too much. I do it so much, in fact, that I no longer have any idea what current versions of browsers actually require to complete a successful XHR.

I'm not a jQuery hater - far from it. I use the shit out of some jQuery, I'm always trying to fix the ways I use it incorrectly, and I think it's extremely handy. Initially I was no fan of it, but at that point I was categorically against any sort of JavaScript library. Once I started using it, I came to appreciate it very quickly, and once I began to appreciate it.. Well, that's how we get to now, where apparently I can't write fucking JavaScript anymore.

I realize I'm hardly the first person to be concerned about reliance on abstractions preventing front-end developers from having a solid grasp of JavaScript, but - pardon me, cause this is douchey - I didn't think that applied to me. Having once had that solid grasp and having applied that knowledge on the daily for a few years, it just never occurred to me that I would lose it if I didn't use it. I thought the people to be worried about were those who were new to JavaScript and, having started out with libraries, never learned the fundamental concepts. It's now much more clear to me how stupid that was. Browsers change all the time (well, most of them). To believe that the correct way of writing JavaScript in 2008 is still the correct way to do it in 2011 is just ridiculous.

For example: when I was trying to update that AJAX document, one of the first things I did was to remove the word "nonstandard" as an adjective describing XMLHttpRequest. That took about half an hour. I was pretty sure it was standard, but I'd never really checked. I still don't really know. The W3C has a document on it, but it's marked "Candidate Recommendation". Does that make it standard? Does the fact that modern browsers have implemented it in a standard way make it standard? Is it not standard until all the browser-specific caveats have been removed from the implementations? Not only was I unfamiliar with the state of those caveats, I didn't really know the disposition of XHR as a standardized concept, and still am not 100% confident in my research on the subject.

And dude, that is sad. I extol the virtues of XHRs at work constantly, in every planning meeting, in every design session. I'm like one of those people on twitter who talks about how awesome Justin Bieber is even though they've never met him. I am a creepy XHR stalker/fan who's based her devotion on an impression that leaves out much of the detail. No one who likes to present herself as a professional front-end developer should be doing that.

So, having realized this, what do I do about it? This is the rub. Probably the best way to maintain a good understanding of JavaScript is to be a library author. I don't mean add another publicly released library to the slew of excellent ones already available, but write internal libraries, creating the same abstractions that I'd normally depend on jQuery or any other library to provide. But that's a little ridiculous. I do write a lot of my own widgets, but that's just because I don't want all the options and config stuff that come with a big, complex, do-everything plugin someone else wrote. Abstractions like jQuery's ajax() are more universal, because they simply wrap a standard* up in a shorter function call. It's good that people can rely on that stuff being in the libraries they use and that that knowledge is useful across a variety of projects. It's probably pretty dumb to create a new XHR abstraction for each new application one works on.

Maybe it's obvious that I'm not sure what to do about my JavaScript knowledge getting stale. I'm not into doing things just to prove I can, but in this case, I'm not sure what would be a better approach. Part of me thinks there may not even be a benefit to staying current on the implementations of common, slightly mundane things like writing out an XHR long-hand. I don't know anyone (aside from library authors, who I only know of) who does their work in plain ol' JavaScript. I like to believe we're moving back to that, though. I always picture jQuery et al as projects that exist to hasten their own obsolescence. Maybe that's crazy and, as someone who merely implements this stuff, I should just embrace the fact that I'm losing the right to call myself a JavaScript developer in exchange for the security of not constantly reinventing the wheel.