Frontend Code Security

Frontend Code Security

3月 12, 2021 · 1 分钟阅读时长 · 81 字 · -阅读 -评论

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:

  1. Build in production mode; strip debug info.

  2. Minify CSS/HTML/JS.

  3. Add hash to CSS class names.

  4. Minify and mangle JS identifiers (e.g., via terser).

    • 比如利用terser

  5. Consider code obfuscation where appropriate.

Alan H
Authors
开发者,数码产品爱好者,喜欢折腾,喜欢分享,喜欢开源