Instead of loading in the page, and then accessing that image, disable the loading entirely by using e.g. `data-src` instead of `src` in the HTML. You then fetch() the URL in that data attribute in your Javascript.
Note that this does mean the images will be delayed from loading, and will cause a layout shift when they're finally inserted. It's best to inline the image's height & width into the HTML if you know them in advance (or use `aspect-ratio`): https://www.aleksandrhovhannisyan.com/blog/setting-width-and...
[0] Just as a note, the tutorial says "<img> tags actually block your application load," which is very wrong.
Here's a straightforward tutorial covering that: https://trezy.com/blog/loading-images-with-web-workers [0]
Note that this does mean the images will be delayed from loading, and will cause a layout shift when they're finally inserted. It's best to inline the image's height & width into the HTML if you know them in advance (or use `aspect-ratio`): https://www.aleksandrhovhannisyan.com/blog/setting-width-and...
[0] Just as a note, the tutorial says "<img> tags actually block your application load," which is very wrong.