The snippet, explained
The Quickstart snippet has five parts. Understanding each means you can adapt it to any stack confidently.
preconnect
Section titled “preconnect”<link rel="preconnect" href="https://cmp.lightning-consent.io" />Opens the TLS connection to the edge early so the first GET /config is fast.
Pure performance; optional but recommended.
The Consent Mode default
Section titled “The Consent Mode default”gtag("consent", "default", { ad_storage: "denied", /* … */ wait_for_update: 500 });Tells every Google tag “assume denied until I say otherwise.” wait_for_update: 500 gives the CMP up to 500 ms to resolve the stored decision before Google
tags act. This block must run before any Google tag. It’s plain
gtag('consent','default',…) — the call Google documents — so it’s safe even if
you don’t use the CMP’s Consent Mode integration.
The async queue stub
Section titled “The async queue stub”!(function (c) { c.lightning = c.lightning || function () { (c.lightning.q = c.lightning.q || []).push(arguments); }; })(window);Defines a temporary lightning() that records calls into a queue; when cmp.js
loads it replays them in order. This is what lets you load the SDK async and
still call lightning('init', …) immediately, without race conditions.
The SDK and init
Section titled “The SDK and init”<script async src="https://cmp.lightning-consent.io/v1/cmp.js?k=YOUR_LICENSE_KEY"></script><script>lightning("init", { theme: "light" });</script>The SDK (~12 KB gzipped), async, never render-blocking. The ?k= license
key authorises backend calls and carries your siteId, so you rarely set it in
init().