@anowlet/cookie-consent
v1.0.2
Published
## A Simple Cookie Consent Manager
Downloads
2
Readme
Cookie Consent
A Simple Cookie Consent Manager
It is a Javascript based solution for blocking / allowing even 3rd party cookies to comply with GDPR & CCPA.
demo
Feature
- Support PC and mobile cookie banner display, responsive
- Lifecycle hooks, giving users the opportunity to add your own code at specific stages
- Multi-lingual, supports EU language
- Support removing unwanted cookies
- Users can customize whether the country complies with CCPA & GDPR
- Support different UA whether to display cookie banner
- Hosted on AWS Cloudfront with edges around the globe for
- Four different blocking methods
Dynamic script tags
Some services insert dynamically created script tags to the HEAD at page load. These can be intercepted and blocked.
Script tag blocking
Some third party services require you to insert a script tag into your HTML pages. These can be inactivated until the user allowes them.
Script wrapping
Some services are not inserted in a SCRIPT tag and are obscured by layers of other code. Thats why this script creates a global wrapper function what you can use to wrap and blovk any JS code.
Local cookies
Finally the local cookies set on your domain can be also filtered by overriding the bowsers COOKIE SET method.
Usage
Module
import CookieConsent from 'cookie-consent';
// or
const CookieConsent = require('cookie-consent');
Classic
<!-- Specify the version -->
<script src="./cookie-consent.umd.js"></script>
<script>
var CookieConsent = window.CookieConsent;
</script>
Initialization
var cc = new CookieConsent({
//...options,
});
Configuration Options
new CookieConsent({
language: 'en',
});
</script>
Instance Methods
Events
cc.on('initialized', (...args) => console.log(args));
cc.on('error', console.error);
cc.on('popupOpened', () => console.log('Popup Open'));
cc.on('popupClosed', () => console.log('Popup Closed'));
cc.on('modalOpened', () => console.log('Modal Open'));
cc.on('modalClosed', () => console.log('Modal Closed'));
cc.on('statusChanged', (...args) => console.log(args));
Browsers support
| IE / Edge | Firefox | Chrome | Safari | iOS Safari | | --------- | --------- | --------- | --------- | --------- | | IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
NPM scripts
npm t
: Run test suitenpm start
: Runnpm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)
Automatic releases
FAQ
Contributions of any kind are welcome!