cookiesEnabled not present in cart.js
See original GitHub issueShopify starter and Slate have a function that looks like the below.
import {cookiesEnabled} from '@shopify/theme-cart';
// Apply a specific class to the html element for browser support of cookies.
if (cookiesEnabled()) {
document.documentElement.className = document.documentElement.className.replace('supports-no-cookies', 'supports-cookies');
}
However the latest version of theme scripts / cart doesn’t have that function cookiesEnabled exporting. This may be related to issue #5
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
How to detect server-side whether cookies are disabled
I dont think there are direct ways to check. The best way is to store a value in the cookie and try to...
Read more >Navigator.cookieEnabled - Web APIs | MDN
navigator.cookieEnabled returns a Boolean value that indicates whether cookies are enabled or not. The property is read-only. Value.
Read more >Reference — Cart.js
If you're not making use of the Data API and are super-concerned with performance, ... Core API methods are available on the global...
Read more >JS examples - Shopify
Tables and video embeds do not natively scale well on smaller screens. ... This makes handling product prices and cart items in JS...
Read more >Strip response cookies enabled - Performance
/cart* /basket* are exceptions which have been added to no avail. ... If every page is cached, it will show the same page...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I work around that error using
navigator.cookiesEnabled
so a simple utility function i put in my own util.js looks like:then in theme.js I remove the theme-cart import and import my own util.js
Haven’t taken the time to really look into it but I started getting this error within the last 24 hours. I did notice that
cookiesEnabled
is still being exported from@shopify/theme-cart/dist/theme-cart.cjs.js
but nowhere else.This is probably a little less ideal, but I ended up going with the following in theme.js to keep everything in one place for now: