Press "Enter" to skip to content

Simple Cross-Browser Cookie Consent Plugin In Vanilla JavaScript | cookieconsent

Cookie Consent Plugin – The simple plug-in has been written to approve the Cookie Consent across the browser in regular JavaScript. A standalone JavaScript library that shows a classy, multilingual, customizable cookie consent popup to make your website adjust to EU Cookie Law.

Click the Learn More link to show Cookie Consent Policy content material in a popup window.

Main characteristics

  • Cross-browser support (IE8 +)
  • Standalone (no external dependencies needed)
  • Lightweight (less than 8KB enhanced / mini version)
  • Support for additional languages can easily be added
  • Automatic detection of browser language
  • There are no additional external HTTP requests

How to make use of it:

1. Insert the JavaScript file cookieconsent.js into the HTML doc.

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();

Stylish Multilingual Cookie Consent Popup, Cookie Consent Libraries, Free Cookie Consent, Cookie Consent Github


See Demo And Download

Official Website(orestbida): Click Here

This superior jQuery/javascript plugin is developed by orestbida. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *