Reduce file sizes by minifying CSS and JavaScript.
Minification removes unnecessary characters from code (whitespace, comments, etc.) without changing functionality. This reduces file sizes and improves load times.
Before:
/* Main styles */
.header {
background-color: #ffffff;
padding: 20px;
}
.header .logo {
width: 100px;
}
After:
.header{background-color:#fff;padding:20px}.header .logo{width:100px}
Before:
// Initialize counter
function incrementCounter(currentValue) {
var newValue = currentValue + 1;
return newValue;
}
After:
function incrementCounter(n){return n+1}
Minification applies to files with these extensions:
.css.jsFiles with .min.css or .min.js extensions are already minified and skipped.
/style.cssFiles containing .min. in the name are skipped:
style.min.css → Skipped
app.min.js → Skipped
Very large files (>1MB) may be served without minification to avoid processing delays.
Source map files (.map) are not minified.
Look for the X-Minified header:
curl -I https://your-zone.cdn.nordiccdn.com/style.css
# Original from origin
curl -so /dev/null -w "%{size_download}" https://origin.com/style.css
# Minified from CDN
curl -so /dev/null -w "%{size_download}" https://cdn.example.com/style.css
Typical savings by file type:
| File Type | Typical Savings |
|---|---|
| CSS | 15-30% |
| JavaScript | 20-40% |
| Already optimized | 5-10% |
Minification is safe for all standard CSS. However, some edge cases:
Minification preserves functionality but:
Keep original, readable code in your repository. Let the CDN handle minification.
After enabling minification:
If you need to debug minified code:
If you already minify during build, either:
.min. to skip processing.css.min.cssCheck browser console for specific errors
Test the original file directly
Look for code that may not minify safely:
eval() usagefunction.toString()Disable minification for problematic files
Minification + gzip/brotli compression stack effectively:
Original: 100 KB
Minified: 70 KB (30% reduction)
Gzip: 15 KB (78% further reduction)
Total: 85% smaller than original
For best results, combine: