Frontend Code Security
·
1 min read
·
81
Words
·
-Views
-Comments
Frontend resources ship to browsers/clients. How do we best protect JS and other assets to reduce risk of code theft in commercial projects? The goal is to raise the barrier and increase the cost of stealing.
Practical measures I’ve used:
Build in production mode; strip debug info.
Minify CSS/HTML/JS.
Add hash to CSS class names.
Minify and mangle JS identifiers (e.g., via terser).
比如利用terser
Consider code obfuscation where appropriate.