diff --git a/eu_cookie_compliance.module b/eu_cookie_compliance.module
index 7b47ca3..ddc55af 100644
--- a/eu_cookie_compliance.module
+++ b/eu_cookie_compliance.module
@@ -308,14 +308,26 @@ function eu_cookie_compliance_page_attachments(&$attachments) {
       }
     }
 
-    $attachments['#attached']['html_head'][] = [
-      [
-        '#type' => 'html_tag',
-        '#tag' => 'script',
-        '#value' => 'function euCookieComplianceLoadScripts() {' . $load_disabled_scripts . 'Drupal.attachBehaviors();}',
-      ],
-      'eu-cookie-compliance-js',
-    ];
+    if (!empty($load_disabled_scripts)) {
+      $attachments['#attached']['html_head'][] = [
+        [
+          '#type' => 'html_tag',
+          '#tag' => 'script',
+          '#value' => 'function euCookieComplianceLoadScripts() {' . $load_disabled_scripts . 'Drupal.attachBehaviors();}',
+        ],
+        'eu-cookie-compliance-js',
+      ];
+    }
+    else {
+      $attachments['#attached']['html_head'][] = [
+        [
+          '#type' => 'html_tag',
+          '#tag' => 'script',
+          '#value' => 'function euCookieComplianceLoadScripts() {' . $load_disabled_scripts . '}',
+        ],
+        'eu-cookie-compliance-js',
+      ];
+    }
 
     // Add inline css.
     $attachments['#attached']['html_head'][] = [
