Introduction

Lightweight Cookie Notice JS is a vanilla JavaScript script that provides an easy way to display a cookie notice on your website. It integrates a large number of customization options, support for multiple cookie categories, and geolocation.

Examples

Options

This script has a total of 100 options. To use an option, set its value during the initialization process.

lwcnCookieNotice.initialize({
  cookieNoticeMainMessageText: 'By clicking "Accept all cookies", you agree that our use of cookies.',
  cookieNoticeButton2Text: 'Accept all cookies',
});
NameTypeDefaultDescription
headingsFontFamilystring'\'Open Sans\', Helvetica, Arial, sans-serif'The font family of the headings.
headingsFontWeightnumber600The font weight of the headings.
paragraphsFontFamilystring'\'Open Sans\', Helvetica, Arial, sans-serif'The font family of the paragraphs.
paragraphsFontWeightnumber400The font weight of the paragraphs.
strongTagsFontWeightnumber600The font weight of the strong tags.
buttonsFontFamilystring'\'Open Sans\', Helvetica, Arial, sans-serif'The font family of the buttons.
buttonsFontWeightnumber400The font weight of the buttons.
buttonsBorderRadiusnumber4The border radius of the buttons.
containersBorderRadiusnumber4The border radius of the containers.
cookieNoticeMainMessageTextstringCustom HTMLThe text of the message displayed in the cookie notice.
cookieNoticeMainMessageFontColorstring'#666666'The font color of the message displayed in the cookie notice.
cookieNoticeMainMessageLinkFontColorstring'#1e58b1'The font color of the links included in the message displayed in the cookie notice.
cookieNoticeButton1Textstring'settings'The text of the button 1 of the cookie notice.
cookieNoticeButton1Actionstring1The action performed after clicking the button 1 of the cookie notice. The possible values are: '0' (Disabled), '1' (Cookie Settings), '2' (Accept Cookies), '3' (Close Cookie Notice), '4' (Redirect to URL)
cookieNoticeButton1Urlstring''The URL where the user will be redirected after clicking the button 1 of the cookie notice.
cookieNoticeButton1BackgroundColorstring'#ffffff'The background color of the button 1 of the cookie notice.
cookieNoticeButton1BackgroundColorHoverstring'#ffffff'The background color of the button 1 in hover state of the cookie notice.
cookieNoticeButton1BorderColorstring'#1e58b1'The border color of the button 1 of the cookie notice.
cookieNoticeButton1BorderColorHoverstring'#1e58b1'the border color of the button 1 in hover state of the cookie notice.
cookieNoticeButton1FontColorstring'#1e58b1'The font color of the button 1 of the cookie notice.
cookieNoticeButton1FontColorHoverstring'#1e58b1'The font color of the button 1 in hover state of the cookie notice.
cookieNoticeButton2Textstring'Accept'The text of the button 2 of the cookie notice..
cookieNoticeButton2Actionnumber2The action performed after clicking the button 2 of the cookie notice. The possible values are: '0' (Disabled), '1' (Cookie Settings), '2' (Accept Cookies), '3' (Close Cookie Notice), '4' (Redirect to URL)
cookieNoticeButton2Urlstring''The URL where the user will be redirected after clicking the button 2 of the cookie notice.
cookieNoticeButton2BackgroundColorstring'#1e58b1'The background color of the button 2 of the cookie notice.
cookieNoticeButton2BackgroundColorHoverstring'#1e58b1'The background color of the button 2 in hover state of the cookie notice.
cookieNoticeButton2BorderColorstring'#1e58b1'The border color of the button 2 of the cookie notice.
cookieNoticeButton2BorderColorHoverstring'#1e58b1'The border color of the button 2 in hover state of the cookie notice.
cookieNoticeButton2FontColorstring'#ffffff'The font color of the button 2 of the cookie notice..
cookieNoticeButton2FontColorHoverstring'#ffffff'the font color of the button 2 in hover state of the cookie notice.
cookieNoticeButtonDismissActionnumber0The action performed after clicking the dismiss button of the cookie notice.
cookieNoticeButtonDismissUrlstring''The action performed after clicking the dismiss button of the cookie notice.
cookieNoticeButtonDismissColorstring'#646464'the color of the dismiss button of the cookie notice.
cookieNoticeContainerPositionnumber2The position of the cookie notice. The possible values are: '0' (Top), '1' (Center), '2' (Modal)
cookieNoticeContainerWidthnumber1140The width of the wrapper that includes the content of the cookie notice.
cookieNoticeContainerOpacitynumber1The opacity of the background of the cookie notice.
cookieNoticeContainerBorderWidthnumber0The width of the border of the cookie notice.
cookieNoticeContainerBackgroundColorstring'#ffffff'The background color of the cookie notice.
cookieNoticeContainerBorderColorstring'#e1e1e1'The opacity of the background of the cookie notice.
cookieNoticeContainerBorderOpacitynumber1The opacity of the border of the cookie notice.
cookieNoticeContainerDropShadowbooleantrueThe drop shadow of the container. The possible options are: '0' (Disabled), '1' (Enabled)
cookieNoticeContainerDropShadowColorstring'#242f42'The color of the mask displayed behind the cookie notice.
cookieNoticeMaskbooleantrueA mask placed behind the cookie notice to prevent user interactions with the website. The possible options are: '0' (Disabled), '1' (Enabled)
cookieNoticeMaskColorstring'#242f42'the color of the mask displayed behind the cookie notice
cookieNoticeMaskOpacitynumber0The opacity of the mask displayed behind the cookie notice.
cookieNoticeShakeEffectnumbertrueA shake effect will be applied on the cookie notice when the user click on the mask. The possible options are: '0' (Disabled), '1' (Enabled)
cookieSettingsLogoUrlstring''The URL of the logo.
cookieSettingsTitlestring'Cookie Settings'The title of the cookie settings modal window.
cookieSettingsDescriptionHeaderstringCustom HTMLThe description displayed in the header of the cookie settings modal window provided as simple text or HTML.
cookieSettingsToggleOnColorstring'#3a70c4'The color of the active toggles displayed in the cookie settings modal window.
cookieSettingsToggleOffColorstring'#808080'The color of the inactive toggles displayed in the cookie settings modal window.
cookieSettingsToggleMiscColorstring'#808080'The color of the miscellaneous toggles displayed in the cookie settings modal window.
cookieSettingsToggleDisabledColorstring'#e5e5e5'The color of the disabled toggles displayed in the cookie settings modal window.
cookieSettingsSeparatorColorstring'#e1e1e1'The color of the borders.
cookieSettingsChevronColorstring'#6e6e6e'The color of the chevron icon displayed in the cookie settings modal window.
cookieSettingsExpandCloseColorstring'#6e6e6e'the color of the expand icon displayed in the cookie settings modal window.
cookieSettingsDescriptionFooterstringCustom HTMLThe description displayed in the footer of the cookie settings modal window.
cookieSettingsButton1Textstring'Close'The text of the button 1 of the cookie settings modal window.
cookieSettingsButton1Actionnumber2The action performed after clicking the button 1 of the cookie settings. The possible values are: '0' (Disabled), '1' (Accept Cookies), '2' (Close Cookie Settings), '3' (Redirect to URL)
cookieSettingsButton1Urlstring''The URL where the user will be redirected after clicking the button 1 of the cookie settings modal window.
cookieSettingsButton1BackgroundColorstring'#ffffff'The background color of the button 1 of the cookie settings modal window.
cookieSettingsButton1BackgroundColorHoverstring'#ffffff'The background color of the button 1 in hover status of the cookie settings modal window.
cookieSettingsButton1BorderColorstring'#1e58b1'The border color of the button 1 of the cookie settings modal window.
cookieSettingsButton1BorderColorHoverstring'#1e58b1'The border color of the button 1 in hover state of the cookie settings modal window.
cookieSettingsButton1FontColorstring'#1e58b1'the font color of the button 1 of the cookie settings modal window.
cookieSettingsButton1FontColorHoverstring'#1e58b1'the font color of the button 1 in hover state of the cookie settings modal window.
cookieSettingsButton2Textstring'Accept'The text of the button 2 of the cookie settings modal window.
cookieSettingsButton2Actionnumber1The action performed after clicking the button 2 of the cookie settings. The possible values are: '0' (Disabled), '1' (Accept Cookies), '2' (Close Cookie Settings), '3' (Redirect to URL)
cookieSettingsButton2Urlstring''The URL where the user will be redirected after clicking the button 2 of the cookie settings modal window.
cookieSettingsButton2BackgroundColorstring'#1e58b1'The background color of the button 2 of the cookie settings modal window.
cookieSettingsButton2BackgroundColorHoverstring'#1e58b1'This option determines the background color of the button 2 in hover state of the cookie settings modal window.
cookieSettingsButton2BorderColorstring'#1e58b1'the border color of the button 2 of the cookie settings modal window.
cookieSettingsButton2BorderColorHoverstring'#1e58b1'The border color of the button 2 in hover state of the cookie settings modal window.
cookieSettingsButton2FontColorstring'#ffffff'The font color of the button 2 of the cookie settings.
cookieSettingsButton2FontColorHoverstring'#ffffff'The font color of the button 2 in hover state of the cookie settings.
cookieSettingsHeadingsFontColorstring'#222222'The font color of the headings of the cookie settings modal window.
cookieSettingsParagraphsFontColorstring'#666666'The font color of the paragraphs of the cookie settings modal window.
cookieSettingsLinksFontColorstring'#1e58b1'The font color of the links of the cookie settings modal window.
cookieSettingsContainerBackgroundColorstring'#ffffff'The background color of the cookie settings modal window.
cookieSettingsContainerOpacitynumber1.0The opacity of the background of the cookie settings.
cookieSettingsContainerBorderWidthnumber0The width of the border of the cookie settings.
cookieSettingsContainerBorderColorstring'#e1e1e1'The border color of the cookie settings modal window.
cookieSettingsContainerBorderOpacitynumber1.0The opacity of the cookie settings container border.
cookieSettingsContainerDropShadownumbertrueThe drop shadow of the container. The possible options are: '0' (Disabled), '1' (Enabled)
cookieSettingsContainerDropShadowColorstring'#242f42'The color of the drop shadow of the cookie settings container.
cookieSettingsContainerHighlightColorstring'#f8f8f8'The highlight color of the cookie settings modal window.
cookieSettingsMasknumbertrueA mask placed behind the cookie settings modal window to prevent user interactions with the website. The possible options are: '0' (Disabled), '1' (Enabled)
cookieSettingsMaskColorstring'#242f42'The color of the mask displayed behind the cookie settings modal window.
cookieSettingsMaskOpacitystring0.54The opacity of the mask displayed behind the cookie settings modal window.
enableGeolocationnumberfalseThe cookie notice will be displayed only to the users located in the countries defined with the geolocationLocale option. The possible options are: '0' (Disabled), '1' (Enabled)
geolocationServicenumber0The geolocation service used to detect the user location. The possible options are: '0' (hostIP), '1' (MaxMind GeoLite2)
geolocationLocalearray[
'at',
'be',
'bg',
'cy',
'cz',
'dk',
'ee',
'fi',
'fr',
'hu',
'ie',
'it',
'lv',
'lt',
'lu',
'mt',
'nl',
'pl',
'pt',
'sk',
'si',
'es',
'se',
'gb']
The list of countries where the cookie notice should be displayed. The countries should be specified with the ISO 3166-1 alpha-2 code.
responsiveBreakpointnumber700When the browser viewport width goes below this value, the mobile version of the cookie notice and cookie settings modal window will be used.
cookieExpirationnumber3153600000The amount of time the cookies used to store the acceptance status and the accepted categories should be stored.
reloadPagebooleanfalseWith this option enabled, when the user accepts the cookies, the page is reloaded.
cookieTableColumnsarray['name', 'expiration', 'purpose']The columns included in the table used to display the cookies.
cookieTableColumnsNamesobject{
name: 'Name',
expiration: 'Expiration',
purpose: 'Purpose',
provider: 'Provider',
domain: 'Domain',
type: 'Type',
sensitivity: 'Sensitivity',
security: 'Security',
}
The names of the columns included in the table used to display the cookies.
forceCssSpecificitybooleantrueThe CSS specificity will be force with the "!important" rule. The possible options are: '0' (Disabled), '1' (Enabled)
ajaxUrlstring'geolocation/init.php'The URL used to retrieve the geolocation information when the GeoLite2 database is used.
sectionsarray[]The data associated with the cookie categories. Please see the examples included in this manual for more details.