Noticed a lot of people complaining, like me, about how intolerably long it takes lightboxes to open whether by code or Editor settings. It usually takes at least 2-3 seconds for even an empty lightbox to open on first instance (they usually open quickly on subsequent triggers).
In the Editor you can go into Lightbox settings and set the delay (default 2 seconds) to 0, which may help. I am not aware of any default delay when opening an unlinked lightbox by code, though it certainly feels like there is one. The long lag has site visitors clicking the trigger button repeatedly because they think it isn’t working.
The prefetchPageResources() API is supposed to speed up lightbox opening by pre-loading some of the resources before the site visitor triggers the lightbox to open. Here is an example set for three lightboxes named Payments, ShowCoupon and BookingTerms.
const response = wixSiteFrontend.prefetchPageResources({
lightboxes: ["Payments", "ShowCoupon", "BookingTerms"],
});
if (response.errors) {
console.log("Could not prefetch the lightboxes :" + response.errors)
}
I’ve added it within my pages’ onReady(), and it appears to be running ok, but honestly can’t see any improvement in the initial lightbox open speeds. Wondering if anyone else has, or has suggestions to tweak it.