diff --git a/ds.module b/ds.module
index 34a5cb77..a3c0a7b7 100644
--- a/ds.module
+++ b/ds.module
@@ -458,12 +458,15 @@ function template_preprocess_ds_entity_view(&$variables) {
   $build = array_merge($build, $layout->build($regions));
 
   // Disable CSS files when needed.
-  if ($build['#ds_configuration']['layout']['disable_css']) {
+  // Add extra checks to bypass warnings disable_css.
+  if (isset($build['#ds_configuration']['layout']['disable_css'])) {
     $library = $build['#ds_configuration']['layout']['library'];
-    $attached = $build['#attached']['library'];
+    if (!empty($library)) {
+      $attached = $build['#attached']['library'];
 
-    $index = array_search($library, $attached);
-    unset($build['#attached']['library'][$index]);
+      $index = array_search($library, $attached);
+      unset($build['#attached']['library'][$index]);
+    }
   }
 
   $variables['content'] = $build;