Page Load Optimization -- Specific Clarifications

From posts in this Forum and after reading Wix documentation, there are some factors regarding optimization of page loading and function that remain unclear. I hope members here might provide clarifications for any of these questions (which are kind of lengthy :thinking:).

  1. Page-side code is a significant factor in slowing page loading. Some Forum posts seem to indicate that the impact is minimized if code for required page-side functions and event handlers is placed in external (export) functions on the page and NOT in the page’s onReady() function. So that code to populate page elements (dropdown element options, button labels, text values, repeater displays) should be in export functions that are called from within the onReady() function. Is this actually the case? Or is the impact of page-side javascript unaffected by such structural differences because the total amount of code is basically the same?

  2. Page caching by Wix seems to provide the greatest page loading benefits. But page-side code generally blocks automatic caching; it must be configured manually. I’m unclear how this works with datasets. If a page has a dropdown selector that filters values in dataset A, with the selector’s options bound to dataset B, and where a repeater’s elements are bound to the filtered values in dataset A–how is this page cached? Does the cached page maintain the dropdown’s options from dataset B with none selected, and load the first page of (unfiltered) values from dataset A into the repeater?

  3. With page caching, when (if possible) should-- Option A: datasets be used (as in #2 above) to provide content for a page, verses – Option B: using code to directly query the content collections for the dropdown and the repeater and to manage the filtering and display and pagination functions for the repeater? Since, with page caching, the code in Option B typically will be executed only occasionally, is there significantly less drag on page performance than with loading the datasets? Or does caching with datasets (#2 above) make utilization of datasets the best choice in most cases?

  4. Wix documentation for “best practices” suggests using local storage to optimize page loading and performance. This approach requires every visitor (including bots) to run all the code at least once for every device they use to access the page. With page caching, only one visitor needs to do this once every caching cycle (e.g., week) to refresh the cached page for all visitors. It would seem that page caching limits the utility of local storage for optimizing page loading/performance only to when the dynamic nature of some other parts of the page prevent page caching. Is this a correct assessment?

  5. Wix documentation also suggests making pages “dynamic” – even when they are not actually templates for multiple pages-- because Wix loads content for dynamic pages sooner (before the page is rendered). The pseudo-dynamic page is created by selecting a collection, but then removing the “slug” from the page URL that normally would function as the filter value for the that collection dataset. How does this actually work? In my example (#2), how would the page load differently (with its two datasets) if one of the datasets was used to make it a pseudo “dynamic” page (no filtering by URL)? Why does a “dynamic” dataset cause page data to load sooner than other datasets? And if only the dynamic dataset loads sooner, does that make any difference if there are other datasets for the page that do not load along with it?

If you’ve read through these, thank you for your patience and any insights you offer. Clarifications about these factors in optimization may be helpful for others as well.

Thanks again.