JavaScript libraries revisited
Published 12 January 2007
Hi! You've stumbled upon a blog post by a guy named Ryan. I'm not that guy anymore, but I've left his posts around because cool URIs don't change and to remind me how much I've learned and grown over time.
Ryan was a well-meaning but naïve and priviledged person. His views don't necessarily represent the views of anyone.
Today PPK rounded up several recent posts debating Javascript Libraries. I defended JS libraries a few weeks ago, but I feel the need to expound. They get a bad rap, and I think its undeserved--especially as the expectations of Web users increase.
When I read James Edwards and Cameron Adams' book1, I was shocked at how neurotic the Javascript was. All kinds of experience is embedded in their notes:
Internet Explorer 5 for Mac doesn't take the
body
's margin or padding into account when calculating the offset dimensions, so if you desire accurate measurements in this browser……
Due to a bug in Safari, it's impossible to cancel the default action of clicking a hyperlink in that browser…
…
Due to a browser bug in Internet Explorer for Windows, the style switcher we used in the previous solution has to be modified slightly…
At times they even bring up rendering differences in Opera 5. I'm not a nine-to-fiver: I'm a working grad student, which makes me a nine-to-midnighter. I don't have the time nor the ability to keep the quirks of individual browser bugs from 2000 when I'm also writing ActionScript, supporting e-mail, doing usability testing writing papers and, oh yeah--living.
There are really two types of libraries: those like Prototype + Scriptaculous or CSSQuery that change the fundamental structure of JavaScript to be more like another language (Ruby and CSS, respectively), and those like the YUI Library that simply attempt to normalize JS across browsers.
While both of these styles of libraries allow you to build rich functionality quickly, I prefer the latter. When you're learning Prototype, you're not really learning JS--you're learning Prototype. On the otherhand, I feel like working with YUI has made be a better JavaScript programmer even when not using the library.
JavaScript libraries allow me to do amazing things that work in all browsers (usually). They allow me to focus on functionality and not browser nuances. Wake me up when all the browsers flawlessly implement E4X and W3C DOM. Until then, I'll hit the snooze button let the (more talented) people a Yahoo! worry about the details.
Tagged with YUI, Javascript, and Web Design.