Recently our good friends at Infinum built an open-source Ruby gem to make it easy to comply with the law if you’re building a Rails-based site. The gem was soon ported to PHP and .NET as well, and we briefly thought about doing a Django port as well.
Then we took a step further: Why would you need to copy the script to your server? Why couldn’t you just copy-paste a single line into your HTML page and be done with it? Turns out, you can, and that’s what we built.
Of course there’s loads of options if you need to customize it, including changing the text, colors or banner position.
The Geek Stuff
- no jQuery for DOM modifications or event listening, we’re using createElement, addEventListener and friends directly,
- no external CSS, we set the default style directly on the HTML elements but still allow customization using CSS,
- no external images or custom fonts, so we’re using Unicode for the close button.
To make the customization easy (including specifying the text and the more info URL), we’re using data-attributes on a script tag. While not something you can see often, in this case this allowed us to be able to have all the customization in one place, without you needing to add additional placeholder HTML tags or linking external CSS sheets.
Come to the EU. We have cookies.