Code Optimization and Formatting
WebZone provides minification and formatting tools for JavaScript, HTML, and CSS. Minification reduces code size by applying optimizations and removing unnecessary formatting. Beautification improves readability by producing consistently formatted source code.
JavaScript Minification
WebZone uses Terser for JavaScript minification.
Usage
- Select the JavaScript Minification tool.
- Paste JavaScript into the input area.
- Configure the optimization settings.
- Click Minify.
- Review the optimized output.
Configuration
| Option | Default | Description |
|---|---|---|
| Mangle | Enabled | Shortens eligible names |
| Compress | Enabled | Applies code optimizations |
| Drop unused | Disabled | Enables unused-code and dead-code removal |
| Remove comments | Disabled | Removes comments when selected |
| ECMA | 2020 | Targets ECMAScript 2017, 2020, or 2022 |
Compression uses two optimization passes when enabled.
Example
Input:
function greet(name) {
const message = "Hello, " + name;
return message;
}Possible minified output:
function greet(e){return"Hello, "+e}The exact result depends on Terser and the selected settings.
Output Statistics
The JavaScript minifier reports:
- Original size in bytes
- Minified size in bytes
- GZIP-compressed size when supported
- Bytes saved
- Percentage reduction
Download
The generated file is named script.min.js.
Caution: Identifier mangling and compression can affect code that relies on dynamically referenced names. Test minified code before deploying.
HTML Minification
HTML minification reduces markup size by removing or simplifying selected content.
Usage
- Select HTML Minification.
- Paste HTML markup.
- Configure the options.
- Click Minify.
- Review or download the output.
Configuration
| Option | Default |
|---|---|
| Collapse whitespace | Enabled |
| Remove comments | Enabled |
| Minify inline JavaScript | Enabled |
| Minify inline CSS | Enabled |
The implementation also configures the minifier to:
- Retain closing slashes
- Retain attribute quotes
- Retain empty attributes
Example
Input:
<div class="message">
<h1>Hello, World!</h1>
<p>Welcome to WebZone.</p>
</div>Possible output:
<div class="message"><h1>Hello, World!</h1><p>Welcome to WebZone.</p></div>Download
The generated file is named index.min.html.
Caution: Whitespace is meaningful in some HTML contexts. Inspect the generated markup before publishing.
CSS Minification
WebZone uses CSSO to optimize CSS.
Usage
- Select CSS Minification.
- Paste the CSS.
- Select the desired options.
- Click Minify.
- Review the optimized stylesheet.
Configuration
| Option | Default | Description |
|---|---|---|
| Remove comments | Disabled | Controls comment removal |
| Purge unused @keyframes | Disabled | Attempts to remove unused animation definitions |
The implementation enables CSSO restructuring.
Example
Input:
.example {
color: #ffffff;
margin: 0px;
padding: 10px;
}Possible output:
.example{color:#fff;margin:0;padding:10px}Unused Keyframe Purging
When enabled, WebZone examines animation references within the supplied CSS and attempts to remove unreferenced @keyframes rules before minification.
This analysis is not project-wide. It may miss references from JavaScript or other stylesheets.
Download
The generated file is named styles.min.css.
Code Beautification
WebZone includes three formatting tools:
| Tool | Parser |
|---|---|
| JavaScript Beautification | Babel via Prettier |
| HTML Beautification | HTML via Prettier |
| CSS Beautification | CSS via Prettier |
Usage
- Select the desired Beautification tool.
- Paste the source code.
- Click Format.
- Review the formatted output.
Example
Input:
const add=(a,b)=>{return a+b}Possible formatted output:
const add = (a, b) => {
return a + b;
};Download Files
| Tool | Filename |
|---|---|
| JavaScript Beautification | script.formatted.js |
| HTML Beautification | index.formatted.html |
| CSS Beautification | styles.formatted.css |
Recommended Workflow
For development:
- Beautify code for readability.
- Validate source where appropriate.
- Minify assets when preparing production builds.
- Test the generated output.
Formatting and minification are not substitutes for testing.
Updated 10 days ago
