🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@uncinc/cookie-consent

Package Overview
Dependencies
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uncinc/cookie-consent

Cookie consent package for non headless frontend websites

latest
npmnpm
Version
1.2.0
Version published
Maintainers
6
Created
Source

Cookie consent package for non headless frontend websites

How to implement in a non headless project in jquery:

Implement the following block in your main JS file, replacing YOUR_THEME with the proper folder:

    $(once('cookie-banner', 'html')).each(function(e) {
      const body = document.getElementsByTagName('body')[0];
      const div = document.createElement('div');
      div.id = 'uncinc-cookie-compliance';
      body.appendChild(div);

      $.getJSON('/themes/YOUR_THEME/cookie/cookie-consent.json', function(data){
          window.cookieBannerSettings = data;
          const head = document.getElementsByTagName('head')[0];
          const script= document.createElement('script');
          script.type= 'text/javascript';
          script.src= '/themes/YOUR_THEME/cookie/uncinc-cookie.min.js';
          head.appendChild(script);
      });
    });

Add a cookie consent json with the properties you want to set to the component, and include a build js from this project in the project as well in the proper folder.

See for example this JSON example:


{
  "loadDelay": 1000,
  "title": "Test",
  "manualText": "Zelf instellen",
  "acceptAllText": "Alles accepteren",
  "acceptSelectionText": "Selectie Accepteren",
  "onlyNecessaryText": "Alleen benodigde",
  "cookieContentsShowMore": "Toon meer",
  "cookieContentsShowLess": "Toon minder",
  "manualHeader": true,
  "cookieLevels": [
    {
      "value": "necessary",
      "label": "Nodig",
      "description": "Beschrijving",
      "disabled": true,
      "consentOptions": ["security_storage"]
    },
    {
      "value": "preferences",
      "label": "Voorkeuren",
      "description": "Beschrijving",
      "disabled": false,
      "consentOptions": ["functionality_storage", "personalization_storage"]
    },
    {
      "value": "statistics",
      "label": "Statistieken",
      "description": "Beschrijving",
      "disabled": false,
      "consentOptions": ["analytics_storage"]
    },
    {
      "value": "marketing",
      "label": "Test",
      "description": "Beschrijving",
      "disabled": false,
      "consentOptions": ["ad_personalization", "ad_user_data", "ad_storage"]
    }
  ],
  "defaultValues": {
    "necessary": true,
    "preferences": false,
    "statistics": false,
    "marketing": false
  },
  "bodyContents": "<h3>Welkom bij 'naam klant'</h3><p>Accepteer je deze cookies? <a href=\"test\"> zie onze cookie link </a></p>"
}

The component can be styled from the outside.

FAQs

Package last updated on 26 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts