Open joliss opened 10 years ago
Any ideas on how to improve jsesc’s performance?
I guess this is the cost we pay for the additional functionality compared to js-string-escape, no?
I'd be surprised if there's anything fundamentally stopping us from optimizing jsesc. If I wanted to optimize jsesc, I'd probably try different approaches to the inner escape loop.
I remember trying a bunch of implementations for js-string-escape, and replace
surprisingly turned out to be quite fast, despite the closure function.
For escaping strings, jsesc is about 10x slower than js-string-escape:
This turns out to be relevant in practice: Building my sample JavaScript app takes twice as long when I use jsesc.