How website assets are compressed with HubSpot and generator?
Automatic Processes Handled by HubSpot
- Minification: HubSpot automatically minifies CSS and JavaScript files that are included in the Design Manager or uploaded via the HubSpot CLI.
- This process removes unnecessary characters, spaces, line breaks, and comments to reduce file size and speed up the browser's parse time.
- Developers should not upload already-minified code to the Design Manager because HubSpot will attempt to re-minify it, which can cause issues.
- Compression: Text-based files (HTML, CSS, and JS) are compressed using Brotli before being served to browsers. If the client's browser does not support Brotli, it falls back to GZIP compression. Compression reduces the file size for faster transmission over the network.
- File Combining: HubSpot automatically combines all CSS files on a page into a single, combined file to reduce the number of HTTP requests.
- Image Optimization: Images uploaded to the HubSpot File Manager are automatically optimized, compressed, and resized. They are also converted to the more efficient WebP format for supported browsers.
- Content Delivery Network (CDN): All assets (images, CSS, JS) are served via HubSpot's global CDN, ensuring they are delivered from the server geographically closest to the visitor, which drastically reduces latency.
- Caching: HubSpot employs aggressive server-side and browser-level caching. When a page or any of its dependencies (like a module or template) changes, the server caches for that specific page are automatically expired and rebuilt.