Cookie Consent is a lightweight, gdpr compliant cookie consent plugin written in plain javascript. An “all in one” solution that also allows you to write your own cookie policy inside without the need for a dedicated page.
Available data-cc
actions
Any button (or link) can use the custom data-cc
attribute to perform a few actions without manually invoking the API methods.
Valid values:
c-settings
: show settings modalaccept-all
: accept all categoriesaccept-necessary
: accept only categories marked as necessary/read-only (reject all)accept-custom
: accept currently selected categories inside the settings modal
Key features
- Lightweight
- Cross-browser support (IE8+)
- Standalone (no external dependencies needed)
- GDPR compliant
- Support for multi-language
- WAI-ARIA compliant
- Allows you to define different cookie categories with an opt-in/out toggle
- Allows you to define custom cookie tables if you want to clarify the cookies you use
Must Read: How to Create a Simple Cookie Banner Consent Using Bootstrap 4
Cross-Browser Cookie Consent Plugin Details
Post Name | GDPR Cookie Consent Script |
Author Name | orestbida |
Category | Cookies, Popup Plugins |
Official Page | Click Here |
Official Website | github.com |
Publish Date | August 29, 2020 |
Last Update | July 30, 2023 |
Download | Link Below |
License | MIT |
How to make use of it:
1. Insert the JavaScript file cookieconsent.js
into the HTML document.
<script src="./dist/cookieconsent.js"></script>
2. Initialize the library and show the cookie consent popup on the web page load.
CookieConsent.run({ "cc_autorun" : true, "cc_website_name" : "Web Code Flow", "cc_website_url" : "webcodeflow.com", "cc_theme_css" : "./src/cookieconsent.css" // path to theme CSS });
3. Customize the cookie consent popup with the next options.
CookieConsent.run({ // parent contianer cc_container : "body", // auto language detection cc_auto_language: false, // or set language here cc_current_lang : "en", cc_default_lang : "en", // auto display on page load cc_autorun: false, // delay in ms cc_delay: 20, // website name cc_website_name : null, // website URL cc_website_url: null, // enable console log cc_enable_verbose: true, // 30 days cc_cookie_expires : 30, // cookie name cc_cookie_name: "cc_cookie", // theme css cc_theme_css: "/public/assets/css/cookieconsent.css" });
4. API strategies.
// show the cookie consent popup CookieConsent.show(delay); // hide the cookie consent popup CookieConsent.hide(); // clear cookies CookieConsent.clearCookies();
All configuration options
Below is a table that sums up all of the available options (must be passed to the .run() method).
Must Read: A Modal Dialog Bootstrap Cookie Banner Consent Settings and Framework
Option | Type | Default | Description |
---|---|---|---|
autorun | boolean | true | If enabled, show the cookie consent as soon as possible (otherwise you need to manually call the .show() method) |
delay | number | 0 | Number of milliseconds before showing the consent-modal |
mode | string | ‘opt-in’ | Accepted values: – opt-in : scripts will not run unless consent is given (gdpr compliant)– opt-out : scripts — that have categories set as enabled by default — will run without consent, until an explicit choice is made |
cookie_expiration | number | 182 | Number of days before the cookie expires (182 days = 6 months) |
cookie_necessary_only_expiration | number | – | Specify if you want to set a different number of days – before the cookie expires – when the user accepts only the necessary categories |
cookie_path | string | “/” | The path where the cookie will be set |
cookie_domain | string | location.hostname | Specify your domain (will be grabbed by default) or a subdomain |
cookie_same_site | string | “Lax” | SameSite attribute |
use_rfc_cookie | boolean | false | Enable if you want the value of the cookie to be RFC compliant |
force_consent | boolean | false | Enable if you want to block page navigation until user action (check faq for a proper implementation) |
revision | number | 0 | Specify this option to enable revisions. Check below for a proper usage |
current_lang | string | – | Specify one of the languages you have defined (can also be dynamic): 'en' , 'de' … |
auto_language | string | null | Language auto-detection strategy. Null to disable (default), "browser" to get the user’s browser language or “document” to read the value from <html lang=”…”> of the current page. If language is not defined => use specified current_lang |
autoclear_cookies | boolean | false | Enable if you want to automatically delete cookies when the user opts out of a specific category inside cookie settings |
page_scripts | boolean | false | Enable if you want to easily manage existing <script> tags. Check and manage third-party scripts |
remove_cookie_tables | boolean | false | Enable if you want to remove the HTML cookie tables (but still want to make use of autoclear_cookies ) |
hide_from_bots | boolean | true | Disable if you want the plugin to run when a bot/crawler/web driver is detected |
gui_options | object | – | Customization option which allows choosing layout, position, and transition. Check layout options & customization |
onAccept | function | – | The method runs on: 1. the moment the cookie consent is accepted 2. after each page load (if cookie consent has already been accepted) |
onChange | function | – | Method run whenever preferences are modified (and only if cookie consent has already been accepted) |
onFirstAction | function | – | Method run only once when the user makes the initial choice (accept/reject) |
languages | object | – | Check below for the configuration |
See Demo And Download

Official Website(orestbida): Click Here
This superior jQuery/javascript plugin is developed by orestbida. For extra Advanced usage, please go to the official website.