Sunday, January 14th, 2007
JavaScript Scripting Essentials
<>p>Dan Webb asks what are your JavaScript essentials? Those bits and pieces you can’t live without that get copy/pasted from project to project. His pragmatic list includes the $ function, getElementsByClassName, Dean’s event handling, the JS 1.6 array methods, and the DOMContentLoaded event. His full script that he guarantees he _won’t_ support is here.Do you start with a full on framework or library no matter what the project size, or do you have a small script you use similiar to Dan’s? Do you go with a clean slate until you really feel pain, or do you just swear off javascript and start with GWT or a drag and drop IDE?
Related Content:











It’s definitely a very small world… http://blog.360.yahoo.com/blog-Vdrx7eU3fqovesPu9Y8Y?p=24
I use Moo Tools :)
I normally use prototype. Sometimes with script.aculo.us for some effects!
[quote]I normally use prototype. Sometimes with script.aculo.us for some effects![/quote]
too bad that this fat libshit only works in firefox…that fucks up every 10 minutes since the last update. it’s a shame!
I use MooToools. It’s the best tool for me.
@handcoder – looks like somone has a case of the Mondays! I use Prototype as well and some bits n peaces that I have put togeather to compliment it.
I’m a bit of a “notbuilthere” person. Been building my library since before the names “Prototype” and “Dojo” were known, so it’s not so easy to port my work to use either of those.
My own portables include the standards such as addEvent(), X() and $(), and a load of generally useful functions such as date_m2h(d) (translates MySQL dates to Human-readable), isArray(obj), newNumberRange(from,to,pad) (returns an array of numbers, optionally padded (03,04,05, etc)).
There are about 3 dozen functions I bring around project to project. Those are probably the more interesting ones.
On large projects I use prototype + my personal library.
For one-off pages or tiny projects I just write pure naked Javascript.
Mootools is starting to look pretty slick. I might end up using that with some of the new stuff I’ll be doing soon.
I might have to steal the new scriptaculous morph function though (Tobie Langel is a genius).
Thomas… wow wow wow! I only contributed the part that makes the morph accept a class name…! I really doubt that makes me into a genius! ;-)
Prototype ia a MUST! Plus I always inject some additional functions like startsWith(), trim(), normalizeSpaces(),.. for Strings .
And recently I have developed simple JS function createAndSubmitDynamicForm(href) that allow me to use <A HREF – like JSP tags that actually produce HTTP POST :
http://aujava.wordpress.com/2007/01/17/postable-html-links/
Plus sometimes I use Behaviour. Surprisingly enough Sriptaculous is usedonly for unit testing..
Prototype?! Isn’t that about 50+kB large? Plus for all the fun stuff you’d need scriptaculous too, right? Thanks, but I’ll pass. Most of the time I use plain old JS scripts and whenever I want some bells and whistles I use jQuery.