Install nodejs and run npm install
Use npm run build to build related script files and use it in index.html to
demo.
node serve.mjsornpm run devto run dev server.- dev server will serve
index.htmlat the root with watcher on/srcdirectory.
Build and include script in the bottom of <body> with <script>
<script type="text/javascript" src="./cookieConsent.js"></script>
- Add addtional scripts and modify existing scripts in
src/js/scriptsdirectory and import its exported functions toexecuteScriptsfunction insrc/js/scrips.js - Use
hasCookieConsent()to determine if script should be executed in oher places
//example
if (hasCookieConsent()) {
gtag('event', 'event_name', {
'key': 'value',
});
}- add custom options in
.env.
GTAG=G-EXAMPLE_TAG #specified G tag for Google Analytics
PRIVACY_POLICY_URL="example.com/privacy.html" #specified privacy policy link
PORT=3000 # development port