Quick tip – Checking how much time your javascript runtime needs

 

I don’t often run into things where it surprises me how easy a solution is. Much less so with Javascript. This quick tip may be for you.

Recently I had some performance issues with runtime javascript taking a long time. You can use the following commands to check how long it takes for something to run :

console.time('someFunction');

someFunction(); // or some code

console.timeEnd('someFunction');

The console neatly spits out the amount of miliseconds it took. Nice.


Bas Schuiling

Bas Schuiling

Expert on everything web development and WordPress. Is pressing his words when version 1 came out and has been liking it ever since. More than 10 years of work experience in web development and writer of this blog.