mathiasbynens / mathiasbynens/jsesc

Performance for escaping strings

Open
#16 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
800
Forks
54
PR merge metrics
No merged PRs in 30d

Description

For escaping strings, jsesc is about 10x slower than js-string-escape:

```
$ time node -e "var escape=require('jsesc'); for (var i = 0; i < 1000000; i++) { escape('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') }"

real 0m2.490s
user 0m2.485s
sys 0m0.024s
$ time node -e "var escape=require('js-string-escape'); for (var i = 0; i < 1000000; i++) { escape('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') }"

real 0m0.217s
user 0m0.170s
sys 0m0.051s
```

This turns out to be relevant in practice: Building my sample JavaScript app takes twice as long when I use jsesc.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Node.js benchmarks shown in the issue and inspect the jsesc escaping entry point and its existing tests. Compare performance with js-string-escape while preserving jsesc's escaping behavior; done means the reported slowdown is materially reduced and the test suite still passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.