You're right;

innerHTML is much, much, MUCH faster to execute (see http:// for numbers). It's also quicker to code and to implement.

However it leaves you with less handles on the elements you're inserting, and 'feels' wrong (in the same way that sometimes a big table is the easiest way to centre content, but doesn't feel right), standards-wise.

I'm a big fan of JS libraries. I use Prototype (and and YUI quite a lot as the basis of a lot of my larger JS-based sites. The advantage of YUI isn't so much its ability to maintain strong standards, but its very strong cross-browser compatibility (so if you use Yahoo.DOM, you're getting a standard DOM across every browser; as with events, etc.).

Prototype's biggest strength is its ability to keep common functions short and simple in your own code files. I can perform complex AJAX throughout a webapp with maybe three lines of JS (plenty of PHP, mind you).

I've never really tried jQuery, because it's been marketed wrong for me. I've been using Javascript since ~1998 and have been doing things with it the "old" way (when everyone declared their variables on a global scope and functions were all called on the onclick, onmouseover events explicitly in code, and when anything fancy was called DHTML). I've spent the years since then developing my syntax and thinking to keep in line with the industry, and am comfortable with the syntax people have come to associate with "new" Javascript (Object notation, DOM manipulation, etc.). jQuery is marketed as a way to change JS syntax significantly (with a view to greater speed, marketed as a sort of Rails on the client side), which would mean a massive change for someone who already has four different programming/ scripting languages to flick between on a daily basis (not counting HTML and CSS syntax). I've heard only good things from people starting out with JS though.



List Guidelines:

Reply via email to