https://www.xtrawine.com/cdn/shop/t/101/assets/algolia-collection-…?v=144937021769275072671773245331
1const AlgoliaPerformanceUtils={debounce(func,delay){let timeoutId;return function(...args){clearTimeout(timeoutId),timeoutId=setTimeout(()=>func.apply(this,args),delay)}},throttle(func,limit){let inThrottle;return function(...args){inThrottle||(func.apply(this,args),inThrottle=!0,setTimeout(()=>inThrottle=!1,limit))}},searchCache:new Map,facetsCache:new Map,maxCacheSize:50,currentMarket:null,checkAndInvalidateCache(newMarket){this.currentMarket&&this.currentMarket!==newMarket&&(this.searchCache.clear(),this.facetsCache.clear(),ALGOLIA_PRODUCTION_MODE||console.log(`Cache cleared - market changed from ${this.currentMarket} to ${newMarket}`)),this.currentMarket=newMarket},generateCacheKey(query,filters,page,sort,market){return JSON.stringify({query,filters,page,sort,market})},getCachedResult(query,filters,page,sort,market){if(["lowest_price","highest_price","vintage_newest","vintage_oldest","most_discounted","most_awarded","new_in"].includes(sort))return null;const key=this.generateCacheKey(query,filters,page,sort,market),cached=this.searchCache.get(key);return cached&&Date.now()-cached.timestamp<3e5?cached.data:null},setCachedResult(query,filters,page,sort,market,result){const key=this.generateCacheKey(query,filters,page,sort,market);if(this.searchCache.size>=this.maxCacheSize){const firstKey=this.searchCache.keys().next().value;this.searchCache.delete(firstKey)}this.searchCache.set(key,{data:result,timestamp:Date.now()})},clearExpiredCache(){const now=Date.now(),ttl=3e5;for(const[key,value]of this.searchCache.entries())now-value.timestamp>ttl&&this.searchCache.delete(key);for(const[key,value]of this.facetsCache.entries())now-value.timestamp>ttl&&this.facetsCache.delete(key)},clearCache(){this.searchCache.clear(),this.facetsCache.clear()},batchDOMUpdates(updates){return new Promise(resolve=>{requestAnimationFrame(()=>{const measurements=updates.filter(u=>u.type==="read").map(u=>u.fn());requestAnimationFrame(()=>{updates.filter(u=>u.type==="write").forEach(u=>u.fn()),resolve(measurements)})})})},setupLazyLoading(){if("IntersectionObserver"in window){const imageObserver=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){const img=entry.target;img.dataset.src&&(img.src=img.dataset.src,img.removeAttribute("data-src"),imageObserver.unobserve(img))}})},{rootMargin:"50px 0px",threshold:.1});return document.querySelectorAll("img[data-src]").forEach(img=>{imageObserver.observe(img)}),imageObserver}return null},optimizeSearchParams(params){const optimized={...params},lowestPriceKeyReference=`meta.xtrawine.omnibus_price-${getMarketReference()}`;return params.clickAnalytics&&(optimized.clickAnalytics=!0),optimized.attributesToRetrieve=["id","inventory_quantity","inventory_policy","objectID","id","title","vendor","handle","image","images","price","compare_at_price","market_pricing_hkd","market_pricing_chf","market_pricing_gbp","market_pricing_dkd","market_pricing_sek","market_pricing_usd","market_pricing_eur","available","product_type","tags","meta.xtrawine.vintage","meta.xtrawine.FormatDescriptionShort","meta.xtrawine.formatDescription","meta.xtrawine.alcoholPercentage","meta.xtrawine.alcoholRange","meta.xtrawine.zone","meta.xtrawine.availability-eu","meta.xtrawine.availability-hk","meta.xtrawine.country","meta.xtrawine.preorderOrderedQty-eu","meta.xtrawine.preorderOrderedQtyAvailabilityDate-eu","meta.xtrawine.awardsListFilter","meta.xtrawine.philosophyListFilter","meta.xtrawine.awardsListJson",`${lowestPriceKeyReference}`],optimized.attributesToHighlight=["title","vendor"],optimized.attributesToSnippet=["title:15"],optimized.enableRules=!0,optimized.facets&&optimized.facets.length>10&&console.warn("\u26A0\uFE0F Too many facets requested, performance may be affected"),optimized},async prefetchNextPage(instance,currentPage){if(!instance.enablePrefetch){console.log("\u23F8\uFE0F Prefetch disabled");return}if(!instance||typeof currentPage!="number")return;const nextPage=currentPage+1,currentMarket=getMarketPricingField(),marketKey=currentMarket?currentMarket.replace("market_pricing_",""):"default",cacheKey=this.generateCacheKey(instance.currentQuery||"",instance.currentFilters||{},nextPage,instance.currentSort||"popularity",marketKey);if(this.searchCache.has(cacheKey)){console.log(`\u2705 Page ${nextPage} already cached - prefetch skipped`);return}if(instance.prefetchInProgress.has(cacheKey)){console.log(`\u23F3 Page ${nextPage} prefetch already in progress - skipped`);return}try{instance.prefetchInProgress.add(cacheKey);const params=instance.buildSearchParams();params.page=nextPage,console.log(`\u{1F680} Starting prefetch for page ${nextPage}...`),setTimeout(async()=>{const startTime=Date.now();try{const result=await instance.index.search(instance.currentQuery||"",params);this.setCachedResult(instance.currentQuery||"",instance.currentFilters||{},nextPage,instance.currentSort||"popularity",marketKey,result);const duration=Date.now()-startTime;console.log(`\u2705 Prefetched page ${nextPage} (${duration}ms) - ${result.hits.length} hits ready`)}catch(error){console.warn(`\u274C Prefetch failed for page ${nextPage}:`,error)}finally{instance.prefetchInProgress.delete(cacheKey)}},50)}catch(error){console.warn("Prefetch setup failed:",error),instance.prefetchInProgress.delete(cacheKey)}},optimizedRender(container,htmlContent){if(container){if(!htmlContent){console.warn("\u26A0\uFE0F optimizedRender called with empty content");return}requestAnimationFrame(()=>{container.innerHTML=htmlContent,container.offsetHeight})}},measurePerformance(label,fn){const start=performance.now(),result=fn();if(result&&typeof result.then=="function")return result.then(res=>{const end=performance.now();return console.log(`\u26A1 ${label}: ${(end-start).toFixed(2)}ms`),res});{const end=performance.now();return console.log(`\u26A1 ${label}: ${(end-start).toFixed(2)}ms`),result}},init(){setInterval(()=>{this.clearExpiredCache()},6e5),this.setupLazyLoading(),console.log("\u{1F680} Performance utilities initialized")}};
2//# sourceMappingURL=/cdn/shop/t/101/assets/algolia-collection-performance.js.map?v=144937021769275072671773245331
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.