Most cookie banners are designed to make you click Accept: a bright Accept button, a grey "Manage options" link, five screens of toggles behind it. It's annoying for visitors, and EU regulators have said clearly that rejecting should be as easy as accepting.
So I built Cookie Jar: a small, free (MIT) consent banner that plays fair, with no dependencies and about 16 KB minified. Accept and Reject sit side by side with the same weight, nothing is pre-ticked, and a little cookie button lets visitors change their mind later. When someone says yes, the jar fills up with cookies. When they say no, it gives a small shake. No guilt trips.
Install
<script src="https://cdn.jsdelivr.net/npm/@fluritheme/cookie-jar@1/dist/cookie-jar.global.js" data-auto></script>
import { createCookieJar } from "@fluritheme/cookie-jar";
const consent = createCookieJar({
policyUrl: "/privacy",
categories: ["analytics", "marketing"], // only the ones you actually use
onChange: (choices) => console.log(choices),
});
if (consent.allows("analytics")) startAnalytics();
Blocking scripts until consent, without a tag manager
A banner that asks but loads Google Analytics anyway isn't doing much. The simplest blocking technique I know is the browser's own: a <script> with an unknown type is never executed. So you change your tags like this:
<script type="text/plain" data-consent="analytics"
src="https://www.googletagmanager.com/gtag/js?id=G-XXXX" async></script>
After a yes, Cookie Jar finds those tags and swaps each one for a real script with the same attributes:
document.querySelectorAll('script[type="text/plain"][data-consent]').forEach((old) => {
const cats = old.dataset.consent.split(/[\s,]+/);
if (!cats.every((c) => choices[c])) return;
const s = document.createElement("script");
for (const a of old.attributes)
if (a.name !== "type" && a.name !== "data-consent") s.setAttribute(a.name, a.value);
s.text = old.text;
old.replaceWith(s);
});
You need to create a new element: flipping type on the existing one doesn't make the browser run it. The demo above has an inline script tagged analytics; accept and you'll see it run.
Google Consent Mode v2
If gtag is on the page, the choice is passed on as analytics_storage, ad_storage, ad_user_data and ad_personalization (plus the two preference signals). Set your defaults to denied before the Google tag loads and Cookie Jar handles the update.
The details that make it fair
- Equal buttons. Same size, same row, same prominence. "Choose cookies" opens per-category switches, all off by default.
-
Changeable. The small cookie button reopens the settings any time.
consent.open(true)does the same from your footer link. -
Re-asks when it should. Bump
versionafter you add a new tool and everyone gets asked again. Choices also expire after 180 days by default. -
Readable on your server. Besides
localStorage, the choice goes into a first-partyfluri_consentcookie (e.g.analytics.marketingornecessary) so server code can respect it too. -
Accessible. It's a labelled dialog, keyboard friendly, and the animations respect
prefers-reduced-motion.
One honest note: a banner helps you collect and respect consent, but it isn't legal advice. What you have to ask for depends on the tools you run and where your visitors are.
It's one of the free, MIT-licensed packages behind Fluri, my collection of interactive website effects. If you run WordPress, Shopify or Wix there's a no-code version with live settings.
What's the most dark-pattern cookie banner you've run into?

Top comments (0)