hi, id like to know if its possible to write a script that caches specified pages in the background when you land on a certain page ?
The full code of a Wix page is not available, so there’s basically no way for a script to save (cache) a site page.
You might be interested in the article Caching Your Site’s Pages .
you can also look at this API: https://www.wix.com/corvid/new-reference/wix-site/prefetchpageresources
it allows to pre fetch pages in the background
This is exactly what i was after thanks so much . so how would write it ?
function prefetchPageResources (?):PrefetchResult
https: //samvacquier.wixsite.com/mysite-1// For full API documentation, including code examples, visit Velo API Reference - Wix.com
$w.onReady( function () {
function prefetchPageResources(prefetchItems: https: //samvacquier.wixsite.com/mysite-1/blank): PrefetchResult
});
@samvacquier , You need to follow the code example in the API reference.
let response = wixSite.prefetchPageResources( {
“lightboxes”: [“First Box”, “Second Box”],
“pages”: [“/first-page”, “/second-page”]
} );
if(response.errors) {
// handle errors
}
/*
- response is:
- {
- “message”: “success”
- }
*/
it can prefetch lightboxes and pages - you should put there the lightbox name and the page routes.
dont forget to import WixSite module
what is WixSite module ?
thanks for your help
From the wix-site API documentation , " The wix-site module contains functionality for obtaining information about your site and its pages."
What you need to do is to include an import statement at the top of your code:
import wixSite from 'wix-site';
Thanks, that got rid of the error. And I think its working. But im still getting a flicking when i land on the new page. you can see here http://samvacquier.wixsite.com/mysite-1
I’m loading gifs as bg images to create the transistions. any thoughts ?
@samvacquier If this is happening in your Live site (not Preview), then it might be that your content is being rendered twice - first time server-side, and the second time client-side. See the article Corvid: About the Page Rendering Process for information.
Hmm, I just took a look at your site and I take it back, I don’t believe the issue would be double-rendering since you have the page backgrounds defined as these images.
To be honest, I really didn’t detect a flickering, except since the backgrounds are animated they would have be in sync with each other, otherwise when switching pages you’ll see them flicker between one page’s background and another.
Not really sure what can be done about that. However, the issue doesn’t seem to be related to code. Maybe Wix Customer Care will have some other ideas. It might just be a matter of design. Maybe there’s some sort of calibration that can be performed on your background images would help.
Well that’s great to know you didn’t get the flickering, might just be a prob my end
@samvacquier Might be my eyes.
Thanks for your help. if i use a video as bg instead of a gif, would i be able to code, so that it plays the video and then goes to the next page ?
To be honest, not sure how a video bg is handled. The Video Player element has an onEnded() event handler which could be used. I don’t believe that the bg video has that.
I’ll dig around and see what I can find. Although Wix Customer Care might be able to answer your question.
See the Notes on the page Adding a video to your page background . Sounds as if videos might not work out for you.
Hi sorry to bother you again, but i’m using this bit of code for my transition page, to have it go to a page after a certain amount of time. instead of having to type the full address, is there a way to have it look up the page name instead
import wixLocation from ‘wix-location’ ;
$w.onReady( function () {
setTimeout(() => {
wixLocation.to( “http://samvacquier.wixsite.com/home” );
}, 1700 );
});
See the wix-location.to() API for the link pattern to use for site pages. I believe it’s the first one in the list.