Open Site Navigation

Create a Lazy Loader in Wix

Sometimes you have a lot of content in a database that you would like to display on a page. However, loading all of that content at once can hurt the overall load speed of the page and website. What you can do to prevent that is to use a simple function that will load additional content when the user scrolls down the website.


Learn how to create a lazy load in Wix

Before you insert the code, watch this video to learn how to properly set up your database and content:



Now that you have successfully set up your site for the code, feel free to copy and paste the code from below to your website.


 

export function loadingStrip_viewportEnter(event) { $w("#loadMore").show(); $w("#dataset1").loadMore() .then(() => { $w("#loadMore").hide(); }); }

 

Make sure you change "loadingStrip" to the name of the strip under the repeater and the strip that has the loader. Also, change the name your loader to "loadMore".


Now you should have successfully set up the lazy loader on your website. Have fun!