We once avoided using Javascript as much as possible, but the past year or so has seen a renaissance in what used to be known as DHTML, driven mainly by the hype surrounding Ajax. Notes and links go here.
See the listing of Javascript libraries.
Unobtrusive Javascript
It’s well established by now that web pages can and should be written using structural HTML markup and CSS to separate presentation from structure. Unobtrusive Javascript is the idea that client-side code can be written such that a page’s behavior is also abstracted out of the HTML markup. What this tends to mean in practice is that, instead of littering a page’s markup with various onwhatever handlers, JS code called in the head of the document attaches those events to page elements at the time of the page’s onload event.
Pages written using unobtrusive Javascript are more elegant and arguably easier to understand; they’re also more likely to degrade gracefully if a user has disabled Javascript.
The first mention I ever saw of unobtrusive JS was in Stuart Langridge’s article “unobtrusive DHTML and the power of unordered lists.” An unobtrusive Javascript tutorial is available.
JSON
“JSON (JavaScript Object Notation) is a lightweight data-interchange format.” JSON is basically a simple format for program data representation that is intentionally exactly like Javascript’s object/array notation. What this means is that if your server-side code can output JSON data, then your client-side code can unserialize it using eval() and no further parsing. This makes it much more lightweight and easier than using XML, so you can do XMLHttpRequest and Ajax without the ‘X.’
- JSON-PHP — A JSON serializer/unserializer for PHP.
Links
- JavaScript: A Survey of the Language
- A (Re)-Introduction to Javascript — An excellent walkthrough of the language.
- Quick guide to somewhat advanced JavaScript — An excellent introduction to formerly esoteric Javascript features that are becoming essential.
- QuirksMode — The DOM compatibility tables here make this site absolutely essential, and the other reference material is great, too. I wish the site didn’t use frames.
- Javascript OO Primer — Quick introduction to OOP in Javascript.
- Classical inheritance in JavaScript
- Private members in JavaScript — How to hide object members in Javascript.
- Namespacing your JavaScript — How to prevent your JS code from colliding with everybody else’s.
- Show love to the object literal — Explains the object literal syntax, which I had never seen until a year or two ago, but is everywhere now.
- Javascript Array and Object.prototype awareness — some guidelines for coding Javascript libraries that coexist with others