diff --git a/core/includes/common.inc b/core/includes/common.inc
index 4163da2..e0146c8 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1620,9 +1620,23 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
         $setting['ajaxPageState']['theme_token'] = \Drupal::csrfToken()->get($theme_key);
       }
 
+      // Start with adding the added libraries to the ajaxPageState. Collect
+      // them from each css/js files, as they get marked earlier.
+      $libraries = [];
+      $remaining_js = [];
+      $remaining_css = [];
+      array_walk($javascript, function($element, $key) use (&$libraries, &$remaining_js) {
+        if (!empty($element['library'])) {
+          $libraries = array_merge($libraries, $element['library']);
+        }
+        else {
+          $remaining_js[] = $key;
+        }
+      });
+
       // Provide the page with information about the individual JavaScript files
       // used, information not otherwise available when aggregation is enabled.
-      $setting['ajaxPageState']['js'] = array_fill_keys(array_keys($javascript), 1);
+      $setting['ajaxPageState']['js'] = array_fill_keys($remaining_js, 1);
       unset($setting['ajaxPageState']['js']['settings']);
 
       // Provide the page with information about the individual CSS files used,
@@ -1635,11 +1649,23 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
       // overwrite the drupalSettings.ajaxPageState.css object with an empty
       // array.
       $css = _drupal_add_css();
+
+      array_walk($css, function($element, $key) use (&$libraries, &$remaining_css) {
+        if (!empty($element['library'])) {
+          $libraries = array_merge($libraries, $element['library']);
+        }
+        else {
+          $remaining_css[] = $key;
+        }
+      });
+
       if (!empty($css)) {
         // Cast the array to an object to be on the safe side even if not empty.
-        $setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);
+        $setting['ajaxPageState']['css'] = (object) array_fill_keys($remaining_css, 1);
       }
 
+      $setting['ajaxPageState']['library'] = array_unique($libraries);
+
       _drupal_add_js($setting, 'setting');
 
       // If we're outputting the header scope, then this might be the final time
@@ -2037,6 +2063,15 @@ function _drupal_add_library($library_name, $every_page = NULL) {
         'js' => $library['js'],
         'css' => $library['css'],
       );
+
+      // Register that the css/js was added through a particular library. This
+      // is used later in order to fill up the ajaxPageState in _drupal_add_js
+      foreach (array('js', 'css') as $type) {
+        foreach (array_keys($library['js']) as $key) {
+          $elements['#attached'][$type][$key]['library'][] = $library_name;
+        }
+      }
+
       foreach (array('js', 'css') as $type) {
         foreach ($elements['#attached'][$type] as $data => $options) {
           // Set the every_page flag if one was passed.
@@ -2044,6 +2079,7 @@ function _drupal_add_library($library_name, $every_page = NULL) {
             $elements['#attached'][$type][$data]['every_page'] = $every_page;
           }
         }
+
       }
 
       $added[$extension][$name] = drupal_process_attached($elements, TRUE);
diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index c432706..c38e26b 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -381,8 +381,8 @@
     // Join IDs to minimize request size.
     options.data.ajax_html_ids = ajaxHtmlIds.join(' ');
 
-    // Allow Drupal to return new JavaScript and CSS files to load without
-    // returning the ones already loaded.
+    // Allow Drupal to return new library, JavaScript and CSS files to load
+    // without returning the ones already loaded.
     // @see \Drupal\Core\Theme\AjaxBasePageNegotiator
     // @see drupal_get_css()
     // @see drupal_get_js()
@@ -399,6 +399,11 @@
         options.data['ajax_page_state[js][' + jsFile + ']'] = 1;
       }
     }
+    for (var library in pageState.library) {
+      if (pageState.library.hasOwnProperty(library)) {
+        options.data['ajax_page_state[library][' + library + ']'] = 1;
+      }
+    }
   };
 
   /**
