JavaScript Array Performance: Initialize to Optimize

The JavaScript interpreters in the most popular browsers distinguish between sparse and dense arrays. Hence, you may get more “array-like” performance if you initialize an array before using it. But this trades memory for speed, so it may not always be the best choice.

Trimming trim via razing arrays (JavaScript)

It may well be that for better JavaScript performance, large arrays should be avoided where possible. That seems fairly clear in this case, where an already fast implementation of the missing String.trim() method was made even faster by using much smaller lookup table arrays.

Filling The Cracks

Sometimes the best way to solve a problem is to make it no longer be a problem. This was the case with a problem that I’d created — and have now fixed — in my version of SyntaxHighlighter.

Dumping Hack Flash, It’s a Class, Class, Class

SyntaxHighlighter now preserves whitespace. Kind of. It’s not pure WYSIWYG, but it’s YCAGWYWBIYTSYJMFYGWYN. It’s good enough that we can stop using Flash to access the clipboard.