diff --git a/.gitignore b/.gitignore index 0ca39c0..0915ed6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules dist .DS_Store +/.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 903184b..944500a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.2.1 + +- changed the element on which the 'consent-banner.ready' event is called from document.body to window + +## 1.2.0 + +- added 'consent-banner.ready' event triggered immediate after library loading +- reduced library file size for improved performance + ## 1.1.1 - introduced bundled version with CSS included diff --git a/README.md b/README.md index 5c107c0..e77606b 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ First, include simple CSS for the banner in the `
` of the page: ```html - + ``` Then in the footer you can include the actual JS: ```html - + ``` +Or if you want to load the library script asynchronously, you can use the following `consent-banner.ready` event listener, which will execute the function only when the library is loaded: +```html + + +``` + **INFO:** You can call the `cookiesBannerJs` function whenever, wherever you want, inside it is wrapped with DOM Ready thingy. To make that work you need to prepare **three** things: diff --git a/package.json b/package.json index 6f45190..0b7d2c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tagconcierge/consent-banner", - "version": "1.2.0", + "version": "1.2.1", "description": "A zero-dependency, lightweight (~3kB), consent platform agnostic, cookie banner for any website.", "main": "src/app.js", "keywords": ["consent banner", "consent mode", "gtm consent", "cookie banner"], diff --git a/src/app.js b/src/app.js index 0743cef..652f447 100644 --- a/src/app.js +++ b/src/app.js @@ -407,4 +407,4 @@ window.cookiesBannerJs = function(overrideLoadConsentState, overrideSaveConsentS ready(consentBannerJsMain.bind(null, config)); } -dispatchBodyEvent('ready'); +window.dispatchEvent(new CustomEvent('consent-banner.ready'));