views:

74

answers:

1

Possible Duplicates:
jQuery Standards and Best Practice
Javascript Best Practices

After finding that a website I wrote is leaking memory like crazy, I've started trying to improve the way I write my Javascript/jQuery code.

For instance, instead of writing:

if ($('#elem').is(':checked'))

I can write:

if ($('#elem')[0].checked))

Directly interacting with the DOM rather than using jQuery as the middle man improves on speed, right?

As for memory leaks, should I consider jQuery callbacks to be like closures? If I reference an element in the callback, should I nullify the reference at the end of it's use? Or will the browser take care of that for me?

I'm just after some good tips to keep in mind when writing my code.

A: 

Run all your JS through JSLint

Larry K