-
Notifications
You must be signed in to change notification settings - Fork 15
Blocking scripts
Konstantinos Pappas edited this page Mar 19, 2025
·
4 revisions
In order to be GDPR-compliant, you need to conditionally load third-party scripts once users have given their consent.
In this section, we’ll explore the various ways to block those scripts from running, until the user has given consent.

- Enable Page Scripts, under the “General” tab of the cookie consent plugin
- Configure the “Blocked Scripts” tab (for more information, refer to the Blocked Scripts section of this wiki)
- That’s it! 🎉
The plugin will automatically:
- Scan for any existing
scripttags - Use a mutation observer to watch for changes being made to the DOM tree
-
Monkey patch the
document.createElement()to interceptscripttags
If your theme/plugin contains a <script> tag you can control, you have to:
- Enable Page Scripts, under the “General” tab of the cookie consent plugin
- Set the
typeof yourscripttag to"text/plain" - Set the
data-cookiecategoryattribute to"analytics","targeting", or"preferences"
<script type="text/plain" data-cookiecategory="analytics" src="analytics.js" defer></script>
<script type="text/plain" data-cookiecategory="targeting">
// Targeting JavaScript
</script>