Pick’n’Mix Live Blog

by edds. 2 Comments

Ross Bruniges: Writing jQuery JavaScript that doesn’t suck

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.

Don’t rely on semicolon insertion to fix your JavaScript. JavaScript likes to guess at things, use triple equals for actually true. Douglas Crockford will love you if you lint.

Follow design patterns to keep you sane. use can use the module pattern to keep private parts of your JavaScript hidden away. Avoid over complication. If you break your code down in to bite sized bits upfront you can reuse more of it later.

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.

Accessibility: dont forget focus styles; invalid markup inserted by JavaScript is still invalid markup; tell screen readers when you have updated the 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.

Kornel Lesinski

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.

2 comments on “Pick’n’Mix Live Blog

  1. Kai Chan Vong on said:

    Thanks for organising the talks and to all the speakers.

    Are there likely to be slideshow notes or for it to be posted on HuffDuffer with audio?

  2. Edd Sowden on said:

    You can find the videos for both these talks on vimeo:

    Writing jQuery JavaScript that doesn’t suck: http://vimeo.com/19000264
    HTML5 Transport Protocol: http://vimeo.com/19000639

Leave a Reply

Your email address will not be published. Required fields are marked *

*

HTML tags are not allowed.