mazey-wordpress-utils
    Preparing search index...

    Function setImgLazyLoadingWhenDomReady

    • Set the 'loading' attribute of all images within a specified element to 'lazy', enabling lazy loading. The function only runs once after the page has loaded.

      setImgLazyLoadingWhenDomReady('.site-content');
      

      Parameters

      • selector: string = ".site-content"

        CSS selector for the element that contains the images. Default is '.site-content'.

      Returns boolean

      • Returns true if the function was able to set the images' lazy loading and it hasn't been run before, false otherwise.