Use Sourcerer to Pre-Load/Pre-Connect Image...

Search
Other Pre-Sale questions
Forum

Use Sourcerer to Pre-Load/Pre-Connect Image Files Per Specific Page?

Bryan Gold's Avatar Bryan Gold
Hello,

I'm wondering if it's possible to use sourcerer to pre-load or preconnect the LCP image for that specific page via the article or module that supplies that image on the page.

Thank you!
Peter van Westen's Avatar Peter van Westen ADMIN
How would pre-connecting be possible/useful on the pageload of a page that contains that image?

Either the image loads as part of the initial rendering process (old school normal loading) or the image is lazy loaded.
Please post a rating at the Joomla! Extensions Directory
Bryan Gold's Avatar Bryan Gold
According to Google's guide, it would be helpful to have the image load at the same time as the first element, which can be done with the preloader. These images are from their guide on reducing the Largest Contentful Paint time.



This is what they write in their guide:


Optimize when the resource is discovered
To ensure your LCP resource starts loading as early as possible, it's critical that the resource is discoverable in the initial HTML document response by the browser's preload scanner. For example, in the following cases, the browser can discover the LCP resource by scanning the HTML document response:

The LCP element is an <img> element, and its src or srcset attributes are present in the initial HTML markup.
The LCP element requires a CSS background image, but that image is preloaded using <link rel="preload"> in the HTML markup (or using a Link header).
The LCP element is a text node that requires a web font to render, and the font is loaded using <link rel="preload"> in the HTML markup (or using a Link header).
Here are some examples where the LCP resource cannot be discovered from scanning the HTML document response:

The LCP element is an <img> that is dynamically added to the page using JavaScript.
The LCP element is lazily loaded with a JavaScript library that hides its src or srcset attributes (often as data-src or data-srcset).
The LCP element requires a CSS background image.
In each of these cases, the browser needs to run the script or apply the stylesheet—which usually involves waiting for network requests to finish—before it can discover the LCP resource and could start loading it. This is never optimal.

To eliminate unnecessary resource load delay, your LCP resource should be discoverable from the HTML source. In cases where the resource is only referenced from an external CSS or JavaScript file, the LCP resource should be preloaded with a high fetch priority, for example:


<!-- Load the stylesheet that will reference the LCP image. -->
<link rel="stylesheet" href="/path/to/styles.css">

<!-- Preload the LCP image with a high fetchpriority so it starts loading with the stylesheet. -->
<link rel="preload" fetchpriority="high" as="image" href="/path/to/hero-image.webp" type="image/webp">



Is this possible with Sourcerer?

Thank you,
Bryan
Peter van Westen's Avatar Peter van Westen ADMIN
So that all refers to imagrs that are not in the initial html. Images loaded via javascript or css.
If you have images that are in your html as <img> tags, then you don't need this LPC.

What kind of images are you trying to do this on?
Please post a rating at the Joomla! Extensions Directory
You can only post on this forum if you log in