There are other benchmarking services by JSPerf was best because it had a searchable index of the tests run and their results so you didn't have to keep writing and running your own. I miss it. The closest alternative I have found is MeasureThat.net
You may not always be able to choose the fastest method, there are differences between innerHTML, innerText, textContent and document.write(). InnerHTML supports HTML tags but both textContent and innerText use plain text, but neither of those are fully cross-browser compatible. For more information see
the discussion on Stack Overflow.
Default 0 or (0)
When looping though an array or a string it is common see something similar to:
for (var count=0; count<str.length; count++)
It is actually marginally faster in some browsers and a lot faster in others to test for the end point in the initial declaration by using:
for (var count=0, end=str.length; count<end; count++).
The reason for this is in the first example str.length is evaluated on every iteration of the loop. In the second, it is evaluated just once.
Minifiers, Compressors and Compilers
When using thee tools it should be remembered that the code produced by these minifiers can be difficult to debug and edit. Sometimes difficult to read. For these reasons the code should be written as normal and a copy kept. The minified code can be used on a production web server but the original code kept - just in case.
All major browsers now contain developer and debug tools. Chrome,
the JSFiddle site. Another useful is the
Can I Use site, but that's mostly for CSS and HTML 5.
This page created October 18, 2014; last modified August 8, 2021