Speed up your website by controlling lity.css from GDPR Cookie Compliance Plugin

lighthouse

Although they have announced that in future versions they will stop using lity.css, the reality is that right now the best cookie and GDPR compliance plugin there is, GDPR Cookie Compliance, uses Lity, which sometimes slows down the speed of the websites quite a lot, sometimes up to 8 or 9 seconds.

And this is because the plugin loads Lity from the following paths, with the peculiarity that generally its loading cannot be postponed, nor compressed:

/plugins/gdpr-cookie-compliance/dist/scripts/lity.js /plugins/gdpr-cookie-compliance/dist/styles/lity.css

However, for the time being, the same authors of the plugin recommend using a couple of actions that, added to the functions.php file of the active theme or to your customization plugin, can greatly improve the loading times of your website, despite Lity.

These are these lines:

/* Optimize load GPR plugin lity.css */ add_action( 'gdpr_enqueue_lity_nojs', '__return_false' ); add_action( 'gdpr_cc_prevent_ajax_script_inject', '__return_true' );
Code language: JavaScript (javascript)

Once you save the changes you can check that they improve both the loading times of your website and the score in Lighthouse, and although this website didn’t get a huge improvement(around 2 points) due to it being a testing website, yours should have a bigger improvement.

lighthouse test

With this method, you will see that lity.css becomes a really light resource, that hardly affects the speed of your web.

Read this post in Spanish: Acelera la carga de tu web controlando lity.css GDPR Cookie Compliance

Click to rate this post!
[Total: 0 Average: 0]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top Skip to content