Add free cookie consent banner to your website in 5 mins

Cookies are small text files that are added to the visitors web browser by the website they visit. Cookie consent banners are required to inform the users of the usage of the cookies in order for the website to be transparent about the data collection practices.

cookie consent banner
Photo by Nadi Lindsay on

This post will guide you how you can add cookie consent banner less than 5 mins using Cookieconsent library by osano

It is advisable to include these scripts in common html header or footer that will be included in every page of your website.

First you need to add popup style sheet to your website. copy following and include it in your web page before end of head tag or end of body tag

<link rel="stylesheet" type="text/css" href="" />

Then after the styles you can copy and paste following javascript code

<script src="" data-cfasync="false"></script>
  "palette": {
    "popup": {
      "background": "#3c404d",
      "text": "#d6d6d6"
    "button": {
      "background": "#8bed4f"
  "theme": "classic",
  "type": "opt-in",
  "content": {
    "message": "This website uses cookies to ensure you get the best experience on our website.",
    "dismiss": "Got it",
    "allow": "Allow cookies",
    "link": "privacy policy",
    "href": ""

As you can see in the code we did two things above. First we include the library and then we passed the configurations for popup. let’s go through each function

palette.popup.textpopup text color
palette.popup.backgroundpopup bg color
palette.button.textbutton text color
paletter.button.backgroundbutton text color
themenull | edgeless | classic
typenull | opt-in | opt-out
content.messagepopup message
content.dismissdismiss button text
content.allowallow button text
linkwebsite policy link text
hrefwebsite policy link

Happy coding ! let others know alternative easy to implement plugins you know.