Enhanced Cookie Consent Bar In jQuery - cookie-consent.js

File Size: 29.1 KB
Views Total: 2043
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Enhanced Cookie Consent Bar In jQuery - cookie-consent.js

An easy-to-use and highly customizable cookie consent bar that informs your visitors about the use of cookies in your website.

More Features:

  • Make your comply with the European cookie law
  • Custom cookies notice message.
  • Custom CSS styles.
  • Saves cookie consent information in cookies or web storage.
  • Trigger a function after the user has accepted the policy.

See Also:

How to use it:

1. Load the minified version of the cookie-consent.js plugin after jQuery.

<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/dist/jquery.cookie-consent.min.js"></script>

2. Initialize the plugin to display a basic cookie consent bar on the page.


3. Customize the cookie notice message.

  message: 'This website uses cookies. <a href="https://www.jqueryscript.net/privacy/">Privacy Policy</a>',

4. Apply your own styles to the cookie consent bar. In this example, we're going to fix the cookie consent bar to the top of the page.

  style: "position: fixed; width:100%"

5. Customize the cookie consent button.

  consentMessage: "I understand",
  consentStyle: "",
  acceptClass: "cookieAccept",

6. Determine how to save the cookie consent information.

  // 10 years
  consentTime: 3650, 

  // cookie, local, or session
  storage: "cookie",

7. Enable the development mode.

  testing: true

8. Callback functions.

  onInit: function(){ },
  onConsent: function(){ },
  onTemplate: function(){ console.log(this) },



  • v1.0.19

This awesome jQuery plugin is developed by myspace-nu. For more Advanced Usages, please check the demo page or visit the official website.