Working on scroll position when user goes back to the previous page then same scroll position of the product will show. Here i have lazy load images ajax is triggers multiple times. How can we use debounce script. I have tried like this
$('.test').on('click', function(e){
stateData = {
path: window.location.href,
scrollTop: $(window).scrollTop()
};
const url = new URL(window.location);
window.history.replaceState(stateData, '', url);
stateData = {
path: window.location.href,
scrollTop: 0
};
window.history.pushState(stateData, '', url);
e.preventDefault();
});
Can anyone suggest to me how to handle it?