Novice struggling with onReady coding

I have a dataset connected to repeaters on several category pages. When viewing a category page live, the image placeholders often show up instead of the data, though the text shows up correctly. The problem is intermittent.

The busiest page has about 3mb of images to display and is the worst offender, but it happens on pages with just 500kb. https://www.davidbensonpaintings.co.uk/scottishscenes

What have I done wrong? Here’s my coding below… the other stuff on there is to control Previous/Next buttons on a dynamic page.

I’d really appreciate some help. I can’t charge my client for a website that doesn’t work. Many thanks.

import { local } from ‘wix-storage’ ;

const linkField = “link-portfolio-title” ; // replace this value

$w.onReady( function () {

//TODO: write your page related code here…

$w( "#dataset2" ).onReady(() => { 

    $w( "#repeater1" ).expand(); 
    $w( "#image1" ).tooltip =  "" ; 

const numberOfItems = $w( “#dataset2” ).getTotalCount();

    $w( "#dataset2" ).getItems( 0 , numberOfItems) 
        .then((result) => { 

const dynamicPageURLs = result.items.map(item => item[linkField]);
local.setItem( ‘dynamicPageURLs’ , dynamicPageURLs);
})
. catch ((err) => {
console.log(err.code, err.message);

        }); 

let mode = $w( “#image1” ).fitMode; // “fixedWidth”
$w( “#image1” ).fitMode = “fixedWidth” ;

}); 

});