How to Exclude CookieYes Script from SG Optimizer Plugin
Last updated on August 29, 2024
Overview
Using CookieYes and SiteGround Optimizer (SG Optimizer) together on your WordPress website might lead to compatibility issues that affect the proper functioning of CookieYes. Specifically, the SG Optimizer’s caching and optimisation function may interact with CookieYes’s script, resulting in unexpected behaviour such as an empty or error-prone cookie banner. To prevent this, exclude the CookieYes script from SG Optimizer’s optimization. By doing so, you ensure the proper functionality of CookieYes while still having the benefits of using SG Optimizer.
Steps to exclude CookieYes script from the SiteGround Optimizer plugin
Log in to your WordPress admin dashboard and navigate to Appearance > Theme File Editor.
In the list of theme files on the right, find and click on Theme Functions (functions.php).
Scroll down to the code editor section and add the following snippet at the end of the file:
add_filter( 'sgo_javascript_combine_exclude_ids', 'js_sgo_javascript_combine_exclude_ids' ); function js_sgo_javascript_combine_exclude_ids( $exclude_list ) { $exclude_list[] = 'cookie-law-info-gcm-var-js'; $exclude_list[] = 'cookie-law-info-gcm-js'; $exclude_list[] = 'cookie-law-info-wca'; $exclude_list[] = 'cookieyes-banner'; $exclude_list[] = 'cookieyes'; return $exclude_list; }

Click the Update File button to save the changes. And then, clear the cache of your website to reflect the update. After completing these steps, the cookie banner should no longer be empty or show errors.
Conclusion
By excluding the CookieYes script from SG Optimizer’s optimization process, you can resolve compatibility issues while maintaining the benefits of both plugins. This solution ensures that your website’s cookie consent management functions correctly without compromising on performance optimization.