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.mjs
ornpm run dev
to run dev server.- dev server will serve
index.html
at the root with watcher on/src
directory.
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/scripts
directory and import its exported functions toexecuteScripts
function 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