Ross Bruniges: Writing
Organisation is a key. You are probably not the onlynperson who looks at your code. Other people will have to see it so keep it organised. Use JSLint as it will pick up on future problems that might come and bite you in the future.
Custom events allow you to hook into other bits of code you might want to later on.
Comments can be a time saver when you work in teams as you don’t have to get nudged when someone else is debugging code you worked on. Make sure you keep your comments up to date though.
Documentation design makes you work out what is going to happen ahead of time. It can also make it easy to delegate code if the documentation is already very well written.
Sizzle parses CSS selectors right to left so make your selectors more specific on the right hand size. Cache things you use more than once. It will makenthings faster later on.
Event delegation is where you add events on to parent elements so you only have to add one event and let it bubble. jQuery.live will add the event onto the document so be careful if you have a Dom heavy page.
Things can go wrong they probably will. Be explicit and make sure you add fallbacks if things do go wrong. Be careful using the html5 shiv as it can go wrong if JS is turned off.
Http is everywhere and the whole web is powered by it. Http is a series of requests and responses. Http headers contain information about the document. They are generated by your web server and you usually don’t see them.
In the past web servers were supposed to copy meta tags into the http headers but this didn’t really work. Browsers picked it up but it’s a mess. Don’t do this.
Forcing download of a file: the only way to do it is using http headers. You can use PHP to do this for you. There are bugs in IE that cause the file download to go wrong which cause many people to add more headers. Utf-8 can cause issues son you need to encode filenames properly.
Filename extensions aren’t really needed you just need the appropriate content type. XSS attacks can work by pretending to send files which have the wrong extension. Due to this you can’t rely on extensions and have to look at the content type.
The W3C sent an email saying that browsers should ignore doctypes and work out if it is a HTML document from the content type. Real XHTML is interpreted as XML and this can cause lots of things to break.
The original http spec was written before IE. It still lives and hasn’t ever changed.