Search.../

prefetchPageResources( )

Optimizes resource fetching of pages and lightboxes in the site so they will load faster.

Description

Use the prefetchPageResources() function to optimize resource fetching of pages and lightboxes you think your site visitors are likely to visit next. When the site visitor navigates to those pages or lightboxes, they will load quicker than usual since some of their resources have already been retrieved.

You can only prefetch resources from pages or lightboxes within the current site.

A prefetch is considered successful if the specified pages and lightboxes exist in the current site. If any of the specified pages or lightboxes do not exist, the prefetch operation returns an error status and lists of the pages and lightboxes that were not found.

Authorization

Request

This endpoint does not take any parameters

Response Object

Results of a prefetch.

NAME
TYPE
DESCRIPTION
message
string

A success or failure message.

errors
PrefetchResultError

The errors that occurred.

Status/Error Codes

Was this helpful?

Prefetch resources successfully

Copy Code
1const response = wixSiteFrontend.prefetchPageResources( {
2 "lightboxes": ["First Box", "Second Box"],
3 "pages": ["/first-page", "/second-page"]
4} );
5
6if(response.errors) {
7 // handle errors
8}
9
10/*
11 * response is:
12 *
13 * {
14 * "message": "success"
15 * }
16 */
Prefetch resources unsuccessfully

Copy Code
1const response = wixSiteFrontend.prefetchPageResources( {
2 "lightboxes": ["My Lightbox", "Fake Lightbox"],
3 "pages": ["/my-page", "/nonexistent-page"]
4} );
5
6if(response.errors) {
7 // handle errors
8}
9
10/*
11 * response is:
12 *
13 * {
14 * "message": "some resources not found",
15 * "errors": {
16 * "lightboxes": ["Fake Lightbox"],
17 * "pages": ["/nonexistent-page"]
18 * }
19 * }
20 */