What would be an aproach for lazy load? Revel framework

Hello, I want to load images as the user scrolls down, and my idea was:

When the user arrives on website load first 20 images from the database, once the user scrolled down, send an ajax call to load more, but not sure how to tell the code to load +10 images.

My idea would be to add a stage variable, and as the user scrolls down, increment it, for example, reached the bottom one, stage+1 => stage = 2 send that through the ajax call and in go do stage * 10 = 20, then with mysql, load the default 10 or 20 images + the result of the stage which is 20 here, so a total of 40, then send the response to ajax, empty the page and append all of the images again

Or, count the loaded image with jquery and send the number to Go and when loading from mysql, skip that number of images.

I don’t quite see how this question is related to Go. It is a about dynamic client side web development.

1 Like

Keep client state in a cookie with some kind of identifier for the last image served. Use this to then determine where to start off from and send the requested number of images.