JavaScript development hard earned wisdom

  • use === instead of == for comparison as === doesn't do type coercion (except when you explicitly want it) as == is very, very, broken
  • never pass around dom objects if you can avoid it - use jquery wrapped dom nodes instead
  • view objects should provide a dom() method that gives you the corresponding jquery-wrapped dom object that they represent
  • write tests with qunit - you will have one hell of a time getting everything to work with all browsers otherwise (yeah I'm talking about you IE7!)
  • write more tests with qunit and run them with the automated testrunner every few seconds while you write code
  • filter down the tests to a manageable chunk while you work on a specific peace of code
  • use a webkit based browser to run the tests if you can - they will run _much_ faster
  • If stuff is off-screen - hide it. Some Browsers (Firefox) may allow the user to tab to it otherwise destroying the layout.
  • Do not introduce mutable objects as a member of a prototype definition. They are globally shared between all instances.
  • Use Underscore.js for iteration instead of jQuery. It's api is much better.

There is more, but this is it for the start. :)

Last modified 10 years ago Last modified on 05/27/2010 04:12:28 PM

1.3.15 © 2008-2016 Agilo Software all rights reserved (this page was served in: 0.73761 sec.)