/** * Dutchie Analytics - Frontend JavaScript */ (function($) { 'use strict'; // Lazy load images if ('IntersectionObserver' in window) { const imageObserver = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { const img = entry.target; if (img.dataset.src) { img.src = img.dataset.src; img.removeAttribute('data-src'); observer.unobserve(img); } } }); }); $('.dutchie-product-image img[data-src]').each(function() { imageObserver.observe(this); }); } // Add hover effects $('.dutchie-product-card').on('mouseenter', function() { $(this).addClass('dutchie-hover'); }).on('mouseleave', function() { $(this).removeClass('dutchie-hover'); }); // Optional: Track product views for analytics $('.dutchie-product-card').on('click', function() { const productId = $(this).data('product-id'); if (productId && typeof gtag !== 'undefined') { gtag('event', 'view_item', { 'item_id': productId }); } }); })(jQuery);