1const OPTIMIZELY_REQUIRED_COOKIE_VALUE = 'analytics:yes' 2 3/** 4 * Get the `cookieyes-consent` cookie value 5 * Looks like: `cookieyes-consent=consentid:<string>,consent:yes,action:yes,necessary:yes,functional:yes,analytics:yes,performance:yes,advertisement:yes,other:yes` 6 */ 7function getConsentedCookieCategories() { 8 const cookie = document.cookie 9 .split(';') 10 .find((c) => c.includes('cookieyes-consent')) 11 12 if (!cookie) { 13 return '' 14 } 15 16 return cookie.replace('cookieyes-consent=', '') 17} 18 19function hasRequiredCookieCategory() { 20 if (window.location.hostname === 'localhost' && !window.Cypress) { 21 return true 22 } 23 24 const cookieValue = getConsentedCookieCategories() 25 return cookieValue.includes(OPTIMIZELY_REQUIRED_COOKIE_VALUE) 26} 27 28function loadOptimizelySnippet() { 29 const projectId = 24016540275 30 31 const el = document.createElement('script') 32 el.src = 'https://cdn.optimizely.com/js/' + projectId + '.js' 33 document.head.appendChild(el) 34} 35 36function onPageInit() { 37 if (typeof window === 'undefined') { 38 return 39 } 40 41 if (!hasRequiredCookieCategory()) { 42 /** 43 * Required cookie consent category not set in cookies on pageload, 44 * likely new visitor so skip loading Optimizely until cookies accepted 45 */ 46 return 47 } 48 49 return loadOptimizelySnippet() 50} 51 52onPageInit()
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.