Javascript performance

Yesterday’s deciphering of my own old Javascripts had a purpose. I managed to decipher it, clean it up a little bit, and do something sensible with it; A syntax highlighter, with support for collapsing blocks of code, written entirely in Javascript. I might do a proper writeup on how this works in another entry later [1].


It revealed a number of puzzling effects and browser peculiarities, like MSIE’s refusal to accept CR[Carriage Return]+LF[Linefeed] and plain spaces as printable characters within <pre> elements, and Mozilla-based browsers refusal to accept the <br /> within the same blocks.
Another interesting thing revealed is this: One or more aspects of Opera 7’s Javascript performance is below par. The syntax highlighter relies heavily on regular expressions and for-loops. I’ve created two test cases that show this.
* “Test A”:http://virtuelvis.com/gallery/o7jsperf1/test1.html applies full syntax highlightning and code collapsing of a CSS file, and relies heavily on regular expressions.
* “Test B”:http://virtuelvis.com/gallery/o7jsperf1/test2.html doesn’t apply syntax highlightning, but applies code collapsing. This works as a test of for-loop-execution and string concatenation.
[1] If you attempt to use the syntax highlighter anyway, before I’ve cleaned it up a little more, and written proper documentation, the following licence terms apply: Free for personal and non-commercial usage. For commercial use, contact me.

Previous Post
Comments are closed.