A good start to the learning phase:
- Dom Scripting (Book)
- PPK on JavaScript (Book)
- The JavaScript Anthology (Book)
- Understanding the DOM
- Understanding Scope
- Event deligation
Another useful thing to learn seems to be Closures, which can lead to memory leaks.
Useful looking scripts
- Enumeration (automating the creation of object loops, I think)
- StringBuilder (via).
- Usable auto-focus
- Dynamically change the visible elments.
- Shows which key is which code.
Optimisation
Quite a few tips ‘n tricks:
- Yahoo’s take, including minimisation techniques.
- Merging & caching CSS & JavaScript
- Opera’s JavaScript optimisation articles
- IE JavaScript optimisation (part 1)
- Objectifying JavaScript
- Event handling verses delagation
- Changing styles with JavaScript, as it appearas to have some unexpected effects.
Fixing onLoad
Any script using onLoad
that kicks in once the page has loaded will have to wait for images & assets to load first. What you really want is the DOMContentLoaded
event, but only Moz & Opera support this.
There are a couple of solutions for this, the first (chronologically at least) is Brothercake’s DOMReady script. Another option (using the interesting looking conditional code for IE) is Dean Edward’s window.onload
solution. A variation on that that allows multiple function calls is Jesse Skinner’s addDOMLoadEvent, which I’ll be trying shortly. Or perhaps the YUI libary will cover it?
Accessible JavaScript
JavaScript Libraries
Many are too much, a few have caught my eye, in order of apparent size & complexity:
- DOMAssistant, several good/best practice functions to make JS easier.
- Base2, from Dean Edwards, notable for being a ‘standards based’ library, using current and upcoming standards as it’s basis for creating a cross-browser library.
- jQuery, which uses a small library to allow you to write JavaScript easily, using CSS & Xquery style selectors.
- Yahoo’s user interface library, this one gets my vote: Yahoo respect JavaScript as a language, it has plenty of support & documentation, and they’ve mentioned something about accessibility.
- Dojo, complex (self-building even?), and recently got backing from IBM & Sun.
Thank you for the links. I am going to use the StringBuilder