               // Save view preference
                    storage.setItem('view_preference', 'grid');
                }
            });

            listViewBtn.addEventListener('click', () => {
                if (currentView !== 'list') {
                    currentView = 'list';
                    listViewBtn.classList.add('active');
                    gridViewBtn.classList.remove('active');
                    displayCurrentPage();

                    // Initialize lazy loading after switching views