Sometimes after all day long coding your code becomes not so effective and your code (usually interface related) becomes slow. You have done so many changes and don't exactly know what slowing it down. In cases like this (and of course, plenty other cases) you can test your JavaScript code performance. First of all, you need Firefox browser and Firebug web developers life saver plugin. I can not think of my web programming work without it.
Anyway, Firebug makes available console
variable to your JavaScript page. Console can be used for logging or printing out debugging information to the Firebug console. Console also has one handy method for tracking time in milliseconds.
console.time('timerName'); // Your javascript code to test here console.timeEnd('timerName');
You can use this script to test your JavaScript code. timerName
in the code can be any name for your timer. Don't forget to end your timer using the same name for timeEnd()
.