On Javascript
I'll be the first to say I love Javascript. I have two big Javascript books to my right to prove it. It's one of the greatest things about the web two-point-oh! movement (yes, I hate that term). And I love milk. But I will also be the first to say I hate how some people misuse Javascript.
My main complaint is the use of Javascript menus. If you will, flash back to 1999... no wait, go back earlier than that, let's say... 1997. Okay, that's right. It's 1997 and P. Diddy was Puff Daddy sampling that Police song. Remember the VMAs? Anyway, look at the web and you will see hundreds of tacky, superfluous IE-only menus.
Now flash forward to 2007. Ten years later and Puff Daddy is P. Diddy (or is it just Diddy? who knows) and he's probably sampling some other popular song from the 80s. But guess what's still around? Yes, those superfluous Javascript menus.
Now, don't get me wrong, Javascript for menus is fine---great even---when it's done right, but wrong, it's just awful. Javascript should never be used to create menu items. For one, it's inaccessible: people may be using screen readers, people may have Javascript turned off, or (in most cases) the script is so poorly written that on every single browser (even cross platform) the menu displays in different areas of the screen. Second, the Javascript is easily bloated. Right now I'm having to edit a simple menu that displays to the side when you mouseover its parent item. Great, sounds easy, right? Well no. The menu is created in one Javascript file using strange, unintuitive names. Then the menu is initialized by a "library" in another Javascript file. That file is 29kb. Most Javascript librarys' today do more than just create menus and are smaller than 29kb when minified or compressed. So why use 31kb (including the other file) to create a menu that could easily be created with semantic HTML/CSS markup?
I can understand how Javascript may present itself as the easiest option, and therefore the best---there are thousands of free scripts out there that you plug-in and change a few variables to get working---however, when you really look at it, is this easier? There are simple, semantic and accessible solutions. Solutions that work on every browser (take notice). In today's market, old-Puff Daddy-style Javascript menus won't cut it. Firefox is growing, so is Safari, MSIE somehow hasn't died yet, and Opera is floating somewhere out there. So why use 31kb of Javascript when you can use a few simple lines to make a list appear? Whoever inherits your site will thank you.
The bigger point I am trying to make is there are few reasons to justify using Javascript to create markup. Javascript is for presentation. For web applications, using Javascript to create markup is acceptable, required really, but you should create semantic markup, rely on the DOM, and plug in to existing HTML elements. There is no justification for using Javascript to do something that could easily be done with proper HTML and CSS. If a complaint is it takes more time to get it to work properly than some five-minute Javascript hack, think about the time spent going through 700 hundred of lines of code to make a 5-line menu popup to the right.