| // Initialize any required functionality | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Lazy loading for images | |
| if ('IntersectionObserver' in window) { | |
| const lazyImages = document.querySelectorAll('img.lazy'); | |
| const imageObserver = new IntersectionObserver((entries, observer) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| const img = entry.target; | |
| img.src = img.dataset.src; | |
| img.classList.remove('lazy'); | |
| observer.unobserve(img); | |
| } | |
| }); | |
| }); | |
| lazyImages.forEach(img => imageObserver.observe(img)); | |
| } | |
| }); |