Fill in the blank. Many browsers support native image lazy-loading using the _________ attribute.
- defer
- async
- preload
- loading
Explanation: The correct answer is loading. The loading
attribute is used to enable native lazy-loading for images in HTML documents, allowing browsers to defer the loading of offscreen images until they are needed. By adding the loading='lazy'
attribute to an <img>
tag, developers can instruct the browser to delay the loading of images that are not immediately visible within the viewport, thereby improving page loading performance and reducing bandwidth consumption. This attribute is particularly useful for web pages with a large number of images or long-scrolling content, as it helps prioritize the loading of visible content while deferring the loading of non-visible images until the user scrolls closer to them. Additionally, native lazy-loading provided by the loading
attribute is supported by most modern browsers, making it a convenient and widely-compatible solution for optimizing image loading in web applications. Overall, the loading
attribute enhances the user experience by speeding up page load times and conserving network resources, making it a valuable tool for web developers striving to create fast and efficient websites.