From 6233872cc472be85fdebbede7b1399b680a04bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Tue, 14 May 2024 17:52:49 +0200 Subject: [PATCH 1/2] triggres 'ready' event on window instead of body --- package.json | 2 +- src/app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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')); From 3615943a9677a1d2ce868c00c205fe7ffc62976c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Tue, 14 May 2024 18:36:30 +0200 Subject: [PATCH 2/2] changelog and readme --- .gitignore | 1 + CHANGELOG.md | 9 +++++++++ README.md | 18 ++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) 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: