Minification shortens load time and reduces bandwidth consumption using code and markup size reduction in your web pages and script files. It greatly enhances site performance and accessibility, resulting in enhanced user experience.
As an added benefit, minification helps those using mobile devices and having a limited data plan to reduce bandwidth consumption when visiting your site.
A content delivery network (CDN) automates the minification process — you don’t have to invest time and resources doing it manually. Uncompressed development file versions remain on your server; the CDN automatically copies minified production variants to its caching servers and points of presence (PoPs). It keeps these synchronized with the masters to account for code changes.
Minification is a standard optimization practice for web pages. All major developers of JavaScript libraries (e.g., bootstrap, JQuery, AngularJS) offer minified production deployment versions.
How Does Minification Work?
Good coding practice calls for developers to use well-named variables, spacing and comments when writing HTML, CSS and JavaScript (JS) files. This both enhances code and markup readability during protracted development, and is useful to others downstream who may have to service the code and markup at a later date.
But left untouched, all of the additional white space and other visual aids — the extra human-readable bits — used in this phase can add up to an ever-present performance drag at deployment time.
Unlike file compression, where code has to be uncompressed before being of use, minification simply strips out those extra referenced bits on the fly. Your copied production files remain fully functional. While not impossible, it becomes more difficult for a troubleshooter to look under the hood of a given file and easily decipher the code. But this is merely a set of performance-optimized files; the development masters still reside on your server and remain easily readable by humans.
The missing bits present no problem to web servers and browsers, where the minified production versions are more efficiently parsed. Network traffic is reduced and your site visitors enjoy a better experience while remaining totally unaware of the underlying minification process.
In addition to deleting extra spaces and comments, HTML, JS, and CSS file minification also manipulates variable names to achieve file size reduction.
Here is a development code example:
The original script is 956 bytes. At 582 bytes, here is its minified counterpart:
Minification can yield as much as a 60 percent file size reduction, e.g., the JQuery JavaScript library represents a 176 kb difference between the two versions. To get an idea as to how your JS or CSS code might be minimized, visit www.minifier.org.
CDNs and Front-End Optimization
For any website, reducing file sizes and corresponding page requests is what front end optimization (FEO) is all about. Minification plays a significant role in that process.
But attempting to manually undertake and manage file minification can be laborious. Additionally, doing so is considered to be a bad practice, for it becomes a near-insurmountable task when dealing with a significant collection of large files. Although several automated tools exist to minify code, using them only adds to the burden IT departments face every day. This is due to the need to manually oversee — and keep synchronized — development and corresponding production versions for each file comprising a given website.
For the many copies of your production HTML, CSS and JavaScript file sets stored on the Incapsula global network of data centers, our CDN accelerates your page load times while performing all of your minification housekeeping automatically. No server configuration is required by you, and your entire organization remains protected from cyber threats such as DDoS assaults.
Try Imperva for Free
Protect your business for 30 days on Imperva.