Code smell
Here are some simple tips on how to improve your code. It's really common sense...
Uses indention and spacesUsing indention and spacing can improve code readability a lot. In CSS instead of this: .floater {
position:absolute;
bottom:0;
}
Do this: .floater {
position: absolute;
bottom: 0;
}
Don't invent your own wild styleI stumbled upon this today: function freezeEvent(e) {
if (e.preventDefault) e.preventDefault();
e.returnValue = false;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return false;
}//freezeEvent
IMO it's unreadable - especially since this style is used in a 500 lines long JavaScript file and the author switches between different styles. Structure your code similar to this: function freezeEvent(e) {
if(e.preventDefault)
e.preventDefault();
e.returnValue = false;
e.cancelBubble = true;
if(e.stopPropagation)
e.stopPropagation();
return false;
}
Code
·
Code improvement
·
Design
·
Interesting
·
JavaScript
·
Tips
•
12. Jan 2008
|
|