Last modified: August 22, 2025
Lazy loading assets allows you to defer the loading of the assets until the time when they are actually needed. On the web, this often means downloading the designated content only once the user has gotten sufficiently close to where in the HTML document the asset displays. This technique is one of many suggested for optimizing page performance.
Lazy loading images
Lazy loading options are available for the image and logo fields in custom modules for use in HubL tags and also available in the default image module.
Browser Compatibility
Lazy loading of images via theloading
attribute is supported by most of the popular Chromium-powered browsers (Chrome, Edge, Opera) and Firefox. To learn more about what browsers are supported you can visit caniuse.com. Browsers that do not support the loading
attribute will simply ignore it without side-effects.
Add lazy loading to Image fields using the CLI
To enable lazy loading of images while building with the CMS CLI, add theshow_loading
and loading
keys to the image or logo field in the module’s fields.json
file.
Parameter | Type | Description | Default |
---|---|---|---|
show_loading | Boolean | Controls showing/hiding lazy load controls to the content editor. | False |
loading | String | Determines whether to use lazy loading. Options include: "disabled" or "lazy" | "disabled" |
module.html
file using the following syntax:
Add lazy loading to image and logo fields in HubSpot
To enable lazy loading, add an image or logo field to your custom module, then navigate to the Content options section in the Inspector pane. Then use the Image loading and Available loading options dropdown menus to configure the image loading behavior.
Image loading
The Image loading option will set the value of theloading
attribute in the browser. Options for this include “Default” (default option) which is the default browser loading behavior for the asset. When enabling lazy loading, the image will load once the image reaches a certain distance from the viewport as defined in the distance-from-viewport threshold.
Available loading options
The Available loading options will determine if content editors will be able to see and set the Image loading option while inside of the page, global, and theme content editor panes. Options for this include Do Not Show Controls (default) or Show all controls. Below is a sample of what the page editor would look like with Show all controls selected:
module.html
file using the following syntax: