reference
1. Learning Points
- Use online tools to compress html, css, js
- Learn to analyze the efficiency improvement points before and after compression
2. Solution:
2.1 HTML compression
- Online compression
- nodejs provides the html-minifier tool (compresses the code at the build layer)
- Back-end template engine rendering compression
2.2 CSS compression
- Use html-minifier to compress css in html
- Use clean-css to compress css
Use online compression as shown below.
2.3 js compression and confusion
- Use html-minifier to compress js in html
- Use uglifyjs2 to compress js
- ps: Pay attention to dependencies
3. Compression comparison
- Merged and compressed js
- After the merge, the page blank time (DOMContentLoaded) has been reduced from 2.70s to 936ms now
- Page load time (Load) reduced from 2.93s to 1.24s now