Introduction
Let me start with a confession: I hate cookie banners. Not because I don’t care about privacy — I do. But because most cookie banners are UX cancer. They slow down page load, confuse visitors, and make your site look like a government notice board.
In early 2025, I was redesigning my SaaS landing page. I spent three full days integrating a Consent Management Platform (CMP). The result? A banner that took 1.2 seconds to render, broke my Google Analytics tracking, and still got complaints from users in Germany. I knew there had to be a better way.
That’s when I discovered vibe coding — using AI to generate production-ready code in seconds. I decided to kill the cookie banner. Not literally break the law, but replace the bloated, third-party CMP with a minimal, compliant, AI-generated solution.
This article is the story of how I did it, what code I used, and why vibe coding is now my default approach for boring but critical compliance tasks.
What is Vibe Coding?
Vibe coding is the practice of using AI assistants — like ChatGPT, Claude, or Codex — to generate code based on plain English instructions. You don’t need to write every line yourself. You describe the behavior, and the AI spits out a working snippet. Then you test, tweak, and deploy.
It’s not a replacement for understanding what you’re doing. But for common, repetitive tasks like cookie consent, it’s a massive productivity boost.
The Real Problem with Cookie Banners
If you’ve ever implemented a cookie banner manually, you know the pain:
- Bloated scripts: Most CMPs load 50–100 KB of JavaScript just to show a small bar.
- Third-party dependencies: Many CMPs rely on external CDNs, introducing latency and possible downtime.
- Awful UX: Users click “Accept All” blindly because the “Reject” button is hidden.
- Tracking issues: When scripts load async, Google Tag Manager can fire before consent is given.
Regulations like GDPR (Europe) and ePrivacy don’t require a specific cookie banner implementation. They require informed consent and easy withdrawal. You can achieve that with a 10-line script — if you’re careful.
How I Killed the Cookie Banner with Vibe Coding
Step 1: Define the Requirements
I needed:
1. A small, non-blocking cookie notice (inline banner, no modal overlay).
2. Only two buttons: “Accept” and “Reject”.
3. Block all non-essential cookies until explicit consent.
4. Store consent in a cookie (or localStorage) and respect it on subsequent visits.
5. Provide a way for users to change their decision later (footer link).
Step 2: Describe to AI
I opened my preferred AI coding tool (I use a local instance of Llama 3.1 405B via Ollama for sensitive work, but GPT‑4 is also fine). Prompt:
“Generate a vanilla JavaScript cookie consent script. It should:
- On first visit, show a banner at the bottom of the page with text ‘We use essential and optional cookies. Optional cookies are disabled until you accept.’
- Provide ‘Accept’ and ‘Reject’ buttons.
- On accept: set a consent cookie and load Google Analytics (gtag) and Facebook Pixel.
- On reject: set a consent cookie with value ‘rejected’ and do NOT load any third-party scripts.
- On subsequent visits, read the cookie and do not show the banner if consent is already given.
- Include a function to withdraw consent (set cookie to ‘rejected’ and reload).
- All in a single