Preserve Comments
By default, ByteHide Shield removes most comments during the obfuscation process to reduce file size and eliminate potential clues about code functionality. However, there are cases where you might want to preserve certain comments, such as license information or important documentation.
How It Works
ByteHide Shield allows you to preserve specific comments by adding special annotation tags at the beginning of the comment. When the obfuscator encounters comments with these tags, it will keep them intact in the output code.
The two supported annotation tags are:
@license
: For preserving license information, copyright notices, and legal disclaimers@preserve
: For any other important comments that should be retained
Only comments with these tags will be preserved; all other comments will be removed during obfuscation.
Examples
Preserving License Information
/**
* @license
* MyAwesomeApp v1.0
* Copyright (c) 2025 Example Corp.
* Licensed under the MIT License
*/
const app = new Application();
Preserving Single-Line License
// @license Copyright (c) 2025 Example Corp.
function initializeApp() {
// Implementation
}
Preserving Important Documentation
/**
* @preserve
* This function performs critical calculations for tax processing.
* Do not modify without consulting the finance department.
* Last reviewed: 2025-01-15
*/
function calculateTaxes(income, deductions) {
// Implementation
}
Preserving Implementation Notes
// @preserve Important: This workaround handles a browser-specific issue in Safari
if (isSafari()) {
useAlternativeApproach();
}
Best Practices
- Be selective: Only preserve comments that provide critical information
- Use appropriate tags:
- Use
@license
specifically for copyright and license information - Use
@preserve
for implementation notes, warnings, or other important documentation
- Use
- Place tags at the beginning: The annotation tag should be the first text in the comment
- Avoid sensitive information: Even preserved comments are viewable in the final code
Configuration
You don't need any special configuration to use comment preservation. Simply add the appropriate annotation tags to the comments you want to preserve, and ByteHide Shield will automatically detect and retain them.
Related Features
Comment preservation works well with other exclusion techniques: