Help – I don’t know my JavaScript library!

You may have come across some scripts out in the wild that have different versions available for a few libraries and wondered how it’s done – surely the author didn’t write the same script 5 times, how on Earth would he remember to roll out the bug fixes across all the versions? You may also […]

Do you comment your DOM manipulation?

I’m not talking about commenting your code, although you should be doing that anyway. JavaScript has the ability to create HTML comments: var comment = document.createComment(‘the comment itself’); document.getElementById(‘foo’).appendChild(comment); You can even do it in jQuery: $(‘<!–the comment itself–>’).appendTo(‘#foo’); Now, I know what you’re thinking: why, why would anyone want to create something that doesn’t […]

I hate jQuery fan-boys

Have you ever noticed these people? Ask them the most simple JavaScript question and they’ll respond with the answer in jQuery, even if that answer’s a lot more complicated. I was on a forum and someone asked a question about shortening getElementsByTagName. He wanted to be able to do this: var myInputs = getID(‘myid’).getTag(‘input’); The […]