Remove unnecessary or redundant information
Minifying code is essential for creating efficient, performant, and sustainable web applications. Smaller codebases translate to faster load times, reduced bandwidth consumption, and easier maintenance. This principle applies to both front-end (client-side) and back-end (server-side) code, though the specific techniques may differ. Code should not be minified in not-for-production developer visible situations.
Criteria: Minify code
Remove unnecessary whitespace, comments, and other non-essential characters from code and data files to reduce file sizes and improve loading times. This applies to HTML, CSS, JavaScript, JSON, SVG, and other relevant file types.
Resources
Impact: Low, Effort: Low
GRI | Impact |
---|---|
materials | Low |
energy | Low |
water | Low |
emissions | Low |
Benefits of this guideline
- Performance: Reduced loading times as a result of less data being transferred. Though this does not inherently have an ecological benefit as whitespace is ignored by rendering engines, it does help meet sustainability targets with visitor-based improvements in terms of loading times.
- Conversion: When a page loads quickly, visitors are less likely to abandon their journey or search for their information elsewhere.
Example
-
code
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(g,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,v=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf -
content
jQuery Slim.
Tags:
- CSS
- HTML
- JavaScript
- Performance