JS Blocker



GDPR Cookie consent plugin is a go-to solution to achieve GDPR compliance for your site. The script blocker services incorporated in this plugin allows users to optionally block the script rendered from pre-defined third-party services as per the user’s consent. This can be done either via the automatic script blocker or by manually adding scripts. Both these solutions are server-based, where the page request is expected to hit the server first for script blocking/unblocking services to take effect.

However, in certain cases, these server based solutions may not serve the purpose due to various reasons like extreme cache or conflict with third party plugins and so on. Here the pages will be served based on the cached content and the request will not actually reach the server. Therefore the blocking/unblocking may not behave as expected with the above solution. This can now be overcome by using a client-side script blocking/unblocking service which will do the job irrespective of where it is being served from (server or cache).

The example below will show you exactly how the scripts can be controlled at the client-side (via Javascript). However you need to know that the corresponding services should be disabled from the automatic script blocker; for e.g, if you plan to use a client-side script blocking service for the Facebook pixel you must ensure that this service is disabled under the Script blocker (automatic or extended via filters).

Javascript helper class function can be inserted into the active theme’s header.php. The code snippet below assumes that you have configured the Hotjar script under the Non-necessary and GA script under the Analytics category. Let us see how to disable these scripts via the Javascript code.

The function that primarily achieves this is CookieLawInfo_Accept_Callback(), which is triggered when the user registers their consent. The if (CLI.consent.non_necessary) checks if the consent has been received for the non-necessary category and executes the script entailing it and likewise for the if (CLI.consent.analytics).

Js Blocker

Note:

Missing JavaScript errors that could potentially be blocking your end users from successfully using your site. For details on this exception see the SDK load failure troubleshooting page. Embed Code of Widgets Widget Features. Widget Width: Widgets have dynamic width (i.e. The widget adjusts itself to the available width). Widget Skin: Most widgets are available in nine skin colors (viz. Aqua, Blue, Electric Blue, Gray, Green, Purple, Red, Yellow and White). We would like to show you a description here but the site won’t allow us. Other Option, Using ads.js. I have mentioned that ad blockers disable external JavaScript files that are named as one of the blacklisted keywords, like ads.js. Our simple example below shows a text warning to visitors, asking them to disable AdBlock and loads an external ads.js script that hides the message.

Blocker
    1. The scripts entered as a javascript helper class must be explicitly disabled from the script blocker screen. You can enable or disable the entire script blocker third party services all at once or disable individually using the toggle from the front end.
  1. While using the javascript code, insert the cookie/script category slug in the if condition; e.g, category analytics should be used in the following manner if(CLI.consent.analytics)
  2. If the category slug is a hyphenated word, then it has to be replaced by an underscore; for e.g, if you have a category slug: non-necessary, you should replace the hyphen by an underscore and use as follows: if(CLI.consent.non_necessary).
JS Blocker

Js Blocker Opera

  • Was this article helpful?