Repeater Loading Painfully Slow

Hello,

I am having some trouble with a repeater which has a user-search and user-filter component. It is located here: https://caledoniachamber.wixsite.com/website/find-a-business

This will move over to a premium plan once the speed issue is resolved.

This page takes ages to load and display the data in the repeater. I cannot for the life of me figure out why- it’s all text!

Can anyone look at the code below and tell me if I have done something which is making it run so slowly?

import wixData from "wix-data";
import wixWindow from 'wix-window';
$w.onReady(() => {
});
let lastFiltertitle;
let lastFiltercategory;
let debounceTimer;
export function ititle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#ititle').value, lastFiltercategory);
}, 500);
}
export function icategory_change(event, $w) {
filter(lastFiltertitle, $w('#icategory').value);
}
function filter(title, category) {
if (lastFiltertitle !== title || lastFiltercategory !== category) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('title', title);
if (category)
newFilter = newFilter.contains('category', category);
$w('#dataset1').setFilter(newFilter);
lastFiltertitle = title;
lastFiltercategory = category;
}
}
$w.onReady(function () {
// Run a query that returns all the items in the collection
wixData.query("PlacesToGo")
// Get the max possible results from the query
.limit(100)
.find()
.then(results => {
// Call the function that creates a list of unique titles
const uniqueTitles = getUniqueTitles(results.items);
// Call the function that builds the options list from the unique titles
$w("#icategory").options = buildOptions(uniqueTitles);
});
// Builds an array from the "Title" field only from each item in
// the collection and then removes the duplicates
function getUniqueTitles(items) {
// Use the map method to create the titlesOnly object containing all the titles from the query results
const titlesOnly = items.map(item => item.category);
// Return an array with a list of unique titles
return [...new Set(titlesOnly)];
}
// Creates an array of objects in the form {label: "label", value: "value"} from the array of titles
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle}
return {label:curr, value:curr};
});
}
});

Any help is greatly appreciated!

Your code is very messy. You should only have one $w.onReady per page (it’s not an error to have more than one, but it makes your code much less readable, which might ends by adding other errors).
Please merge them into one, remove all the comments, so it’ll be more readable, and post it again.

hopefully this is right- I’m not familiar enough to know if it’s merged right. Comments are removed.

import wixData from “wix-data”;
import wixWindow from ‘wix-window’;
$w.onReady(() => {
});
let lastFiltertitle;
let lastFiltercategory;
let debounceTimer;
export function ititle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#ititle’).value, lastFiltercategory);
}, 500);
}
export function icategory_change(event, $w) {
filter(lastFiltertitle, $w(‘#icategory’).value);
}
function filter(title, category) {
if (lastFiltertitle !== title || lastFiltercategory !== category) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘title’, title);
if (category)
newFilter = newFilter.contains(‘category’, category);
$w(‘#dataset1’).setFilter(newFilter);
lastFiltertitle = title;
lastFiltercategory = category;
}
}
wixData.query(“PlacesToGo”)
.limit(100)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#icategory”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.category);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
});

No, it’s not. You left the $w.onReady() empty instead of putting everything in it except for the functions. It’s also not clear when do you want to run the wixData.query.

Sorry- I’ve used templates to put this code together. I do not know how to fix it. Any help is appreciated.

Everything that should run once the page elements got loaded should be inside:

$w.onReady(() => {
  //HERE
 });

But all the import and export should not.

  • you should decide what should trigger the data query, and locate the code in accordance.

But if you just combined several existing snippets together, it may be difficult to answer in more details, without knowing the goal.

The goal is to show a list of businesses and their contact information in the repeater where the user viewing the site can search the list or narrow it down using a drop down to sort by category.

as it is right now, it takes up to 20 seconds to show The data in the repeater and it shows just a blank screen for most of that time.

thank you for helping!

So first of all delete this code:

wixData.query("PlacesToGo")
.limit(100)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w("#icategory").options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.category);
return [...new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
});

Instead put the following code inside the $w.onReady() function:

wixData.query("PlacesToGo")
.limit(100)
.distinct("category")
.then(r => {
    let options = r.items;
    options = options.map(e => {return {label: e, value: e};});
    $w("#icategory").options = options;
});

No real solution here - I’ve looked everywhere and I’m having the same issue. The best tool they have with the worst result for customers. (10 second+ load times)

Would love to hear from any Wix staff if they have any plans on making a repeater with at LEAST 50 items more nimble.

Time to move on.

Until the team improves the repeater performance, you can build a repeater using Custom Element (if you have a premium account), it’ll be much faster, but it takes more time to develop.

And if you don’t want to get into this hassle, try to see if loading only a few items with a pagination can work for you.
And off course. We’re all waiting for native repeaters with better performance, and you can be sure the team knows about our need as it has been brought up many times.