Developer utilities · REST API

CSS and JavaScript Minification API

Reduce CSS and JavaScript payload size using dedicated REST endpoints, with standard or advanced optimization modes.

Free tier available. Both endpoints require a JWT Bearer Token.

Key features

Two optimization modes

Use BASIC for standard minification or ADVANCED for modern optimization engines.

Plain-text integration

Send source code as text/plain and receive minified code as text/plain.

Processing metrics

Inspect response headers for the engine, processing time, input/output sizes and compression ratio.

Minify JavaScript

Remove unnecessary whitespace and comments while preserving valid JavaScript semantics. BASIC uses Google Closure Compiler; ADVANCED uses esbuild. Maximum input size: 1 MiB. The endpoint also performs security analysis for potentially unsafe constructs.

Endpoint

POST /api/v1/tools/minify-js?mode=BASIC

Content-Type: text/plain · Accept: text/plain

The mode query parameter is optional and defaults to BASIC. Supply ADVANCED to select the alternative engine.

Example with BASIC mode

Request (text/plain)

function hello() {
    console.log('Hello DevHub');
}
						

Response (text/plain)

function hello(){console.log('Hello DevHub');}
						
Explore JavaScript endpoint in Swagger

Minify CSS

Reduce CSS by removing unnecessary whitespace, comments and redundant semicolons. BASIC uses YUI Compressor; ADVANCED uses Lightning CSS. Maximum input size: 10 MiB.

Endpoint

POST /api/v1/tools/minify-css?mode=BASIC

Content-Type: text/plain · Accept: text/plain

The mode query parameter is optional and defaults to BASIC. Supply ADVANCED to select the alternative engine.

Example with BASIC mode

Request (text/plain)

.a {
   color : red}
.b {
   margin : 0}
						

Response (text/plain)

.a{color:red}.b{margin:0}
						
Explore CSS endpoint in Swagger

Compare optimization modes

Engines and limits for the two endpoints
API BASIC ADVANCED Maximum input
JavaScript Google Closure Compiler esbuild 1 MiB
CSS YUI Compressor Lightning CSS 10 MiB

Response metadata

Both endpoints return the minified content in the response body and expose processing information in HTTP headers.

Response headers
Header Meaning
DevHub-Minifier Minification engine used
DevHub-Processing-Time-Ms Processing time
DevHub-Optimization-Mode Optimization mode used
DevHub-Original-Size-Bytes Original payload size in bytes
DevHub-Minified-Size-Bytes Minified payload size in bytes
DevHub-Engine-Version Engine version
DevHub-Compression-Ratio Compression ratio

Use cases

  • Minify frontend assets in automated build and deployment workflows.
  • Optimize CSS and JavaScript before delivering content to users.
  • Compare minification engines and inspect output-size metrics.
loader