RadLikeWhoa / Countable

Add live paragraph-, word- and character-counting to an HTML element.
https://sacha.me/Countable
MIT License
1.64k stars 134 forks source link

Precompile Regex #8

Closed zackbloom closed 11 years ago

zackbloom commented 11 years ago

It doesn't matter on modern browsers (they cache regular expressions), but on older ones, it can be more performant to define regex outside of the function where they're used, so they don't have to be recompiled on every keystroke.

RadLikeWhoa commented 11 years ago

Can you provide a live example on something like jsperf.com? I'd like to see the actual savings first.

Edit: Tested it myself, didn't really improve performance. In IE7, things even got worse.