Kjeks Scripting
Consent-gate any enqueued script by handle for Kjeks — assign registered script handles to a consent category and they stay inert until the visitor consents.
by Per Søderlind · github.com/soderlind/kjeks-scripting · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/soderlind/kjeks-scripting/releases/download/0.2.0/kjeks-scripting.zipReadme
Kjeks Scripting
Consent-gate any enqueued script by handle for Kjeks.
Assign a registered script handle to a consent category, and the script stays inert until the visitor consents to that category. No code changes to the scripts themselves — you gate them by handle from an admin screen.
Requirements
- WordPress 6.8+
- PHP 8.3+
- The Kjeks plugin (active) — it provides
the consent UI, the script gate, and the shared
AddonKitbase classes.
How it works
- A script is registered/enqueued with a handle (by a theme, plugin, or your
own code) — for example
google-analyticsorhotjar. - On the settings screen you map that handle to a consent category (Analytics, Marketing, or Preferences).
- On the front end the add-on registers each mapped handle with the core Kjeks
blocking registry. Core rewrites the tag to
type="text/plain"withdata-kjeks-category, so the browser does not run it until consent is given.
Settings
- Multisite: Network Admin → Settings → Kjeks Scripting (network-wide).
- Single site: Settings → Kjeks Scripting.
Type or pick a script handle (the field suggests handles registered in the admin), choose its category, and save. Add as many rows as you need; leave a row blank to ignore it.
Finding a handle
Handles are the first argument passed to wp_enqueue_script() /
wp_register_script(). Check the enqueuing plugin/theme, or view source and
look at the id attribute of the `
Read the full README on GitHub →