Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
Terser keep (don't mangle) a specific function name

Is there a way to not mangle only one function name? A comment in the code would be easiest, but I guess this could be done by specifying a custom "nameCache" ? But I don't know how that works.

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I couldn't figure this out, but I already had the function name so I stored the function name on the webpage in an attribute that I could find later with JavaScript. e.g.

function bob() {
  console.log('hello');
}

document.querySelector('#myid').setAttribute('data-function-name', bob.name);
<span id="myid">for example make this style="display:none;"</span>

about 4 years ago · Santiago Trujillo Report

0

To prevent terser from mangling a particular symbol, you need to add it to terser's reserved list. This can be done in your terser options file:

{
    "mangle":
    { 
        "properties":
        {
            "reserved": ["symbolToNotMangle", "anotherSymbolToPreserve"]
        }
    }
}

If you are not already using a terser options file, you would save that off to (for example) terser_options.json and tell terser to use it like so:

terser ... --config-file terser_options.json

You can also just list the reserved symbols on the command line if you prefer:

terser ... -m reserved=['symbolToNotMangle','anotherSymbolToPreserve']

https://github.com/terser/terser#cli-mangle-options

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!