Performant Cookie Consent Banner Example

Read all about this approach on Lessons of a CTO. The heavily-commented code powering this is available open-source on GitHub.

For the purpose of the demo, I've added US/Canada/Australia/New Zealand to the list EU+UK countries requiring consent. If you're outside of these, you'll need to use a VPN or test with something like WebPageTest.

This is the SSR'd page where the consent banner has open added server-side via an edge function.

This should be more optimal for performance than using a client-side JavaScript solution, but of course it has overheads (namely cost) and you'll need to ensure you either have sufficient traffic or cold-start worker performance is good enough.

We use cookies, do you want cookies too?

What cookies do you want?