简体   繁体   中英

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.

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.eg

 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM