Web Development

GDPR Cookie Consent JavaScript Plugin

Riz Ali
Riz
Feb 2, 2021
3 min read
425 words
GDPR Cookie Consent JavaScript Plugin 01

GDPR Cookie Consent JavaScript plugin makes your site and blog to be fulfilled with the European cookie and General Data Protection Regulation (GDPR). This small jQuery plugin adds a simple Cookie Bar with info about cookies which is being used.

GDPR JavaScript Plugin is a simply adapted that contains the ingenious multilingual function. The plugin is used to create a multi-language and customizable cookie permission message to informs visitors that your site uses cookies. New language for Cookie Bar. can be added. You just need to use this addTranslation method.

GDPR Cookie Consent JavaScript Multilingual Plugin

Installation

The easiest ways to download and install this plugin.

Install Via npm

$ npm i kovarp-jquery-cookiebar

Clone repository

$ git clone https://github.com/kovarp/jquery.cookieBar

Add to page

Link plugin CSS file in page head

<link rel="stylesheet" href="jquery.cookieBar.min.css">

Link plugin script file after jQueryJQuery Carousel Slider Free Download – Owl Carousel 2

<script src="jquery.min.js"></script>
<script src="jquery.cookieBar.js"></script>

Using

Examples of plugin using.

Default initialization

$(function() {
	$.cookieBar();
});

Initialization with custom options

$(function() {
	$.cookieBar({
		style: 'bottom'
	});
});

Options

style - Define style of display cookie bar on page

default: 'top'
options: 'top', 'bottom', 'bottom-left', 'bottom-right'
wrapper - Wrapper, where the cookie bar will prepended

default: 'body'
options: string
expireDays - Number of days, when the cookies will expires

default: 365
options: integer
infoLink - URL for "more info link"

default: 'https://www.google.com/policies/technologies/cookies/'
options: string
infoTarget - Targer for "more info link"

default: '_blank'
options: '_blank', '_self', '_parent', '_top'
language - Language of the cookie bar

default: $('html').attr('lang') || 'en'
options: 'ISO 639-1 Language Code'
The default value means, that the plugin detect automatically language from html lang attribute.

privacy - Show privacy protection button (GDPR)

default: false
options: false, 'popup', 'bs_modal', 'link'
privacyTarget - Target attribute for "privacy button link"

default: '_blank'
options: '_blank', '_self', '_parent', '_top'
privacyContent - Content for privacy button

default: null
options: null, 'custom HTML', 'Bootstrap modal ID', 'url'

Languages support

You can add new language for Cookie Bar. Just use this addTranslation method.

$(function() {
	$.cookieBar('addTranslation', 'de', {
		message:	'Zur Bereitstellung von Diensten verwenden wir Cookies. Durch die Nutzung dieser Website stimmen Sie zu.',
		acceptText:	'OK',
		infoText:	'Mehr Informationen',
		privacyText:	'Datenschutz'
	});
});
Then, you can initialize the Cookie Bar with your own language.

$(function() {
	$.cookieBar({
		language: 'de'
	});
});

File Info.

File Size16.90 KB
Last Update5 Months Ago
Published Date3 Years Ago
LicenseMIT
Responsive Touch Image Simple Lightbox jQuery Plugin
Riz Ali

Riz

Author

Riz is a Senior Web Strategist with over 14+ years of hands-on experience in full-stack web design and digital architecture. Having successfully delivered 250+ web projects, he believes passion is the engine of innovation. Riz specializes in translating complex technical concepts into accessible, fanatical content, helping businesses bridge the gap between aesthetic design and high-performance engineering. His work has been instrumental in scaling digital presence for startups and established brands alike.

View all posts

Continue reading

You might also like

Leave a Reply

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

Menu