You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
100kB+ seemed too heavy for a cookie popup so I wrote this. It's currently < 4kB gz/br, including CSS. It's designed to be as small as possible with an adequate featureset for basic website cookie consent.
7
+
100kB+ seemed too heavy for a cookie popup so I wrote this. It's around 4kB gz/br, including CSS. It's designed to be as small as possible with an adequate featureset for basic website cookie consent.
8
8
9
9
- Stores consent in `localStorage`, exposes in `window.Consent` and through custom events fired on `document`
 ([failing due to GTM.js bug](https://github.com/replete/biscuitman/issues/4), pass locally)
34
28
35
29
## How to use
36
30
[View demo](https://replete.github.io/biscuitman) for a more detailed example
@@ -74,6 +68,7 @@
74
68
// more: '(Show more)', // Show more button text
75
69
// noCookies: 'No cookies to display', // Displayed in expanded sections within modal
76
70
// acceptNonEU: false, // When enabled biscuitman checks browser locale timezone to see if it matches EU, if not it will auto consent
71
+
//dialogPolyfillUrl: '//cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.5.6/dialog-polyfill.min.js' // extends browser support, overridable if you want to self-host. Grab the .css too, and host in the same place.
77
72
78
73
message:'By clicking "Accept All", you agree to the use of cookies for improving browsing, providing personalized ads or content, and analyzing traffic. {link}',
79
74
// {link} inside any configuration string will be replaced with an <a> link
@@ -151,7 +146,7 @@ I've included an ESM version as an alternative packaging format. Longterm it's b
151
146
152
147
## Theme CSS
153
148
154
-
It's easy enough to theme the included styles by overriding CSS variables. They are shortened for filsize savings, but straightforward:
149
+
It's easy enough to theme the included styles by overriding CSS variables. They are shortened but straightforward:
155
150
156
151
```css
157
152
/* hacker mode */
@@ -185,15 +180,22 @@ html.bm-show::after {
185
180
186
181
## Browser Support
187
182
188
-
With browserlist, we're targeting `">= 2%, last 2 years"`. This project is tested with BrowserStack. The earliest versions tested working are:
183
+
With browserlist, we're targeting `">= 2%, last 2 years"`. The earliest versions tested working are:
189
184
190
185
- Chrome/Edge/Opera: 85+ (released June 2020)
191
186
- Firefox: 98+ (released March 2022)
192
-
- Safari Desktop+iOS: 15.4+ (released March 2022)
193
-
- I couldn't easily test 15.0-15.3, 14.1 is broken though
187
+
- Safari (inc iOS): 15.4+ (released March 2022)
194
188
- Samsung Internet: 14+ (released April 2021)
195
189
196
-
Currently if this is used in a browser that breaks interactivity (e.g. Safari 14.1, released April 2021), the site is unusable. It might be worth catching errors for unsupported browsers and removing the UI altogether for these extreme edge cases of users not updating their browsers.
190
+
With `v0.3.19`, a [polyfill for dialog](https://github.com/GoogleChrome/dialog-polyfill) is loaded as necessary, extending the support to include these browsers (tested):
191
+
192
+
- Safari (inc iOS): 13.1+ (released March 2020)
193
+
- Firefox: 77+ (released June 2020)
194
+
- Firefox Android: 79+ (released August 2020)
195
+
196
+
If you need to support earlier than these browsers, you will need to start loading polyfills for missing javascript features, starting with `String.prototype.replaceAll`. [Cloudflare's polyfill CDN site](https://cdnjs.cloudflare.com/polyfill) will help you generate a package which will need to load before biscuitman.
197
+
198
+
This project is tested with BrowserStack.
197
199
198
200
## Globals
199
201
-`biscuitman` – configuration object, must be `window.biscuitman` (`biscuitman.create(options)` for ESM version)
@@ -213,10 +215,12 @@ Currently if this is used in a browser that breaks interactivity (e.g. Safari 14
213
215
-`bmOpen()` – Opens My Consent Settings modal (you might want to link this on your Privacy policy or footer nav)
214
216
- example usage: `<a href="javascript:bmOpen();"> Update my consent settings</a>`
215
217
218
+
The ESM version currently does still use some globals.
219
+
216
220
## CSS Classes
217
221
218
222
-`biscuitman` on UI container
219
-
-`bm-{sectionName}`, `bm-no-{sectionName}`, `bm-show` on `<html>`
223
+
-`bm-{sectionName}`, `bm-no-{sectionName}`, `bm-show`and sometimes `bm-dialog-polyfill`on `<html>`
220
224
-`--bm-height` CSS variable written to `<html style="--bm-height:0px;">`
`npm run dev` fires up a browsersync dev server on `https://localhost:3000`.
248
+
`npm run dev` fires up a browserSync development server on `https://localhost:3000`.
245
249
246
-
We need to use `https://` to be able to delete Secure cookies.
250
+
We need `https://` active to be able to delete Secure cookies.
247
251
248
252
### Fix NET::ERR_CERT_AUTHORITY_INVALID error
249
253
250
-
This isn't a problem for testing the UI, but is a problem for the tests running headless browsers. To fix this:
254
+
To prevent invalid certificate warnings, you can generate a local SSL key with `mkcert`:
251
255
- Install `mkcert` ([Installation instructions](https://github.com/FiloSottile/mkcert#installation)) and then run:
252
-
- run `npm run makecerts`, to create`server.crt` and `server.key` for browserSync
256
+
- run `npm run makecerts`, to generate`server.crt` and `server.key` for browserSync dev server
253
257
- if you're using another solution for local SSL certs, generate `server.crt` and `server.key` manually and place them in the root
254
258
255
259
Visiting `https://localhost:3000` should now work without warnings.
256
260
257
261
258
262
### Building
259
-
`npm run build` - creates project distributes via `run.js` a custom build script requiring `Node v20`
263
+
`npm run build` - creates project distributes via `run.js`, a custom build script requiring `Node v20`
260
264
261
265
### Tests
262
266
Jest is set up with puppeteer to run some integration tests. We're using `@swc/jest`'s rust implementation of jest to speed things up. This is only chromium for now, but at some point it would be good to implement browserStack selenium tests to automate browser compatibility checks.
0 commit comments