jQuery Tip: Validate your XHTML!
I’ve just been playing around with jQuery. It’s an amazing framework. It really speeds up development, and make RIA development for the web very easy – much easier than Flash. The only drawback is that browser compatibility becomes an issue. I created a friend manager and avatar builder using jQuery, and after launch I got a lot of reports from users of IE7 on Vista. It seems that jQuery was crashing their browser.
I went back and took a hard look at my implementation and did some digging on the net. I’ve heard reports that malformed XHTML can wreak havoc with the browser’s ability to crawl the DOM. So, I had to go back and make sure I had no XHTML errors. That included th base template and all dynamic updates to the XHTML document. I validated all possible permutations of the XHTML using Firefox’ Web Developer Add-on Tools -> Validate Local HTML.
It seems that making sure all the XHTML was valid solved the problem for most people. I must say, though, that all other browsers were fine with the original implementation – even IE7 on Windows XP. It seems that IE7 for Vista is much more fragile – which is very odd because you’d think IE7 on XP and Vista would behave the same way. So, holding my nose, I just bought a copy of Vista for testing.
On another note – Google Chrome did just fine with it as well. It just did it faster.



jquery isn’t a framework. it’s a library
Comment by jacob — 9/6/2008 @ 9:08 pm
jQuery is no moon. It’s a space station!
Comment by geoff — 9/7/2008 @ 12:32 am
So just to clarify a point, you mentioned this in regards to jQuery:
“The only drawback is that browser compatibility becomes an issue”
That kind of comes off as inferring that when you code in jQuery, that browser compatibility is an issue. From reading the whole post though, it actually seems as if you didn’t have valid markup, in which case you would’ve had issues with traversing the DOM irregardless of which library you used.
The main reason I really want to clear that up is because the jQuery lib is cross browser compatible and we go to great lengths to ensure that.
I also realize that sometimes writing things down in a blog doesn’t come across 100% as you may have anticipated so if I’m off in my thinking, feel free to let me know.
Rey – jQuery Team
Comment by Rey Bango — 9/7/2008 @ 8:21 pm
Rey,
I guess my wording was a bit off. What I meant was that the main drawback to moving from Flash to JavaScript is that you have to consider browser compatibility. In Flash, it pretty much works the same way in all browsers – the only issue is dealing with versions of the plugin.
I wasn’t speaking of jQuery in particular, but the issue of IE7 crashing is real. I’m certain it’s not the fault of jQuery – it’s just that IE is and always will be a cruddy browser.
jQuery is the bees knees. It’s simply awesome. I guess the point of my post is to make sure that people understand it isn’t jQuery that’s the problem if you have invalid XHTML.
Comment by geoff — 9/7/2008 @ 11:23 pm
@ Rey,
Please don’t use “irregardless” – it is not a word!
Comment by Chris — 9/23/2008 @ 8:27 am
jQuery is no moon. It's a space station!
Comment by regtweaker — 1/20/2010 @ 9:01 am
jQuery is the bees knees. It's simply awesome.
Comment by registry cleaner — 1/24/2010 @ 5:15 pm
thanks share!
Comment by freeregistrycleaner — 2/1/2010 @ 4:15 pm