- "classes are for designers", so don't scope with
ids
andclasses
in js. JavaScript developers should use data-* attributes, js-* prefix for classes or role attribute (go to discussion) - prefix jQuery objects with
$
sign unless you are working with angular project (go to discussion) - Detect and inform about network issues, especially in SPA
- Prefer
$(this) over $ (@) in CoffeeScript. - Try to avoid using date.js, use moment.js instead. datejs overwrites native methods and tends to break stuff.
- Use
camelCase
for variable and function names. The only exception to this rule are JSON properties which areunder_scored
. - Use trailing commas in multiline object literails and multiline arrays. If you'd like to add an element you won't left your comma on the previous line. It helps to keep VCS history clean.
// Bad // Good // Bad // Good
let arr = [ let arr = [ let obj = { let obj = {
'foo', 'foo', foo: 'foz', foo: 'foz',
'bar' 'bar', bar: 'baz' bar: 'baz',
]; ]; }; };
- use callbacks instead of low-level
$.ajax
when possible - move javascript tags from
HEAD
to the bottom (go to discussion)