I pop up a lightbox when a user clicks on a row in a table. It takes a few seconds to display, which is extremely frustrating. Can we speed up the lightbox display? Or give me a good old fashioned “dialog box”? I don’t need fancy, I need fast and functional.
Hi,
We will soon release new API called “wixSite.prefetchPageResources” which will do exactly that.
We’ll explain about it in a few weeks at https://www.wix.com/corvid/reference/wix-site.html .
Hope it helps
Ask and you shall receive! That’s great. I look forward to the announcement.
I’m going to play around with it! I saw it popup in the API Reference and was shocked. This is massive!!!
I’m happy to announce prefetchPageResources is live!
Play with it, use it, and ping us if you encounter ANY problems or have feedback to share
https://www.wix.com/corvid/reference/wix-site.html#prefetchPageResources
@Ofer, will it also work with global elements - If I have a ligthbox that is triggered from a button on the header, should I run the prefetch on the site code panel?
@jonatandor35 Yes exactly.
@oferr Thanks. In the documentation you should add
import wixSite from 'wix-site';
It’s obvious, but yet it should be there.
Also I tested it and it looks like it must be inside the $w.onReady(). That needs to be documented too.
Thanks @jonatandor35 Is there anything else that’s needed? I’ve added the code additions from your two comments above but I’m still having issues. My current codes looks like the below. And I don’t know if it matters or not, but I’m using the free version of Wix… So my website URL is similar to xyz.wixsite.com/car-reviews. And the page I’m adding this code to is the ‘corvette’ page. Any advice you have would be greatly appreciated.
import wixSite from ‘wix-site’;
$w.onReady( function () {
let response = wixSite.prefetchPageResources( {
“lightboxes”: [“Mobile Menu”],
“pages”: [“/corvette”]
} );
if (response.errors) {
// handle errors
}
@philwestover I assume that you close the $w.onReady() function somewhere (and you just didn’t paste it).
So it looks like it’s fine (but it’s new for me too).
@jonatandor35 Thanks – and yes, I missed the copy/paste of the function closing. Below is what’s I have so far in its totality.
@oferr – any suggestions? I’m still getting the 3-4 second lightbox delay.
import wixSite from ‘wix-site’;
$w.onReady( function () {
let response = wixSite.prefetchPageResources( {
“lightboxes”: [“Mobile Menu”],
“pages”: [“corvette”]
} );
if (response.errors) {
// handle errors
}
});
@oferr , what about dynamic pages? Can I prefetch them too?
and let’s say I have the following dynamic page:
my-domain.com/title/title-1
my-domain.com/title/title-2
Should I write: pages: [“/title”]
OR: pages: [“/title/title-1”, “/title/title-2”]
Or maybe both are acceptable?
Thanks,
Yes you can!
You can see the page url in Page Settings > Page Info, on the example below it will be:
wixSite.prefetchPageResources( {"pages": ["/dummycollection/Title"]})
‘dummycollection’ is my collection, and ‘Title’ is the dynamic field.
@oferr Thanks. It’s good to know that prefetch works for dynamic pages as well.
Are people seeing much of an improvement??
@stephenmccall not me.
@oferr Are there teething problems? I can’t seem to notice any difference?
All the “import” lines should be at the top of the code.
The prefetch and if(response.errors) should be inside the $w.onReady() curly parnthesis.