I think this is not just a limitation of the LIGHTBOX.
Regarding your CODE → it tells me that you query your DATABASE with every click, right?
Really??? You query your databse again and again and again?
YES YOU DO !!! LOOK HERE…
$w(‘#projectsGallery’).onItemClicked((event) => {
const clickedTitle = event.item.title;
wixData.query("GameOverlay")
Does Chat-GPT agree to my assumtion? ->>>>
Yes, the slowness you’re experiencing is likely because the code queries the database every time an item is clicked. Querying the database repeatedly can be time-consuming, especially if the database is large or if there are many clicks in quick succession.
To improve the performance, you can preload the data when the page is loaded and store it locally in a variable. This way, when an item is clicked, you can access the data immediately without querying the database again.
I think a variable for storing data, was also my idea.
But what next ?
You have to load (QUERY) your DATABASE once on very beginning, thats enough, as long as your data do not change inside your databse.
Let’s say you have queried your DATABASE and stored all the found data inside the following VARIABLE…
—> const gameData;
Now, you start the find-method to find the right CLICKED-DATA inside your VARIABLE, which will exist all time without any further RE-QUERING.
$w('#projectsGallery').onItemClicked((event) => {
const clickedTitle = event.item.title; console.log('Clicked-Title: ', clickedTitle );
// Find the matching game data from the preloaded array
const item = gameData.find(game => game.gameTitle === clickedTitle);
if (item) {
wixWindow.openLightbox("gameOverlay", {
banner: item.banner,
gameTitle: item.gameTitle,
publishDate: item.publishDate,
developer: item.developer,
role: item.role,
description: item.description,
videoLink: item.videoLink,
gameLink: item.gameLink
});
} else {
console.log(clickedTitle);
console.log("No matching item found.");
}
});
Benefits:
- Performance Improvement: Only one database query is made when the page loads, reducing the delay and enhancing the user experience.
- Quick Access: Searching a local array is much faster than querying the database repeatedly.
This should significantly speed up the response when clicking items in your gallery.
Give some feedback, if this provided idea → improved your process.