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

  1. Select the JavaScript Minification tool.
  2. Paste JavaScript into the input area.
  3. Configure the optimization settings.
  4. Click Minify.
  5. Review the optimized output.

Configuration

OptionDefaultDescription
MangleEnabledShortens eligible names
CompressEnabledApplies code optimizations
Drop unusedDisabledEnables unused-code and dead-code removal
Remove commentsDisabledRemoves comments when selected
ECMA2020Targets 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

  1. Select HTML Minification.
  2. Paste HTML markup.
  3. Configure the options.
  4. Click Minify.
  5. Review or download the output.

Configuration

OptionDefault
Collapse whitespaceEnabled
Remove commentsEnabled
Minify inline JavaScriptEnabled
Minify inline CSSEnabled

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

  1. Select CSS Minification.
  2. Paste the CSS.
  3. Select the desired options.
  4. Click Minify.
  5. Review the optimized stylesheet.

Configuration

OptionDefaultDescription
Remove commentsDisabledControls comment removal
Purge unused @keyframesDisabledAttempts 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:

ToolParser
JavaScript BeautificationBabel via Prettier
HTML BeautificationHTML via Prettier
CSS BeautificationCSS via Prettier

Usage

  1. Select the desired Beautification tool.
  2. Paste the source code.
  3. Click Format.
  4. 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

ToolFilename
JavaScript Beautificationscript.formatted.js
HTML Beautificationindex.formatted.html
CSS Beautificationstyles.formatted.css

Recommended Workflow

For development:

  1. Beautify code for readability.
  2. Validate source where appropriate.
  3. Minify assets when preparing production builds.
  4. Test the generated output.

Formatting and minification are not substitutes for testing.


Did this page help you?