diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index bb8b46576b2cc227788a4f1dd3400b153787c6a3..4307d92e1cfc7bee7e592adba39bd20ca0189191 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -1716,7 +1716,8 @@
 
       const allUniqueBundleIds = response.data.map(function (style) {
         const uniqueBundleId = style.href + ajax.instanceIndex;
-        loadjs(style.href, uniqueBundleId, {
+        // Force file to load as a CSS stylesheet using 'css!' flag.
+        loadjs(`css!${style.href}`, uniqueBundleId, {
           before(path, styleEl) {
             // This allows all attributes to be added, like media.
             Object.keys(style).forEach((attributeKey) => {
diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
index 8313a9bb593dafef66df933d5a75d5d819e4af89..96e0a33266077b7e40121c0ed3e2c50a1404bc91 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
+++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
@@ -207,6 +207,10 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInte
       'href' => 'my/file.css',
       'media' => 'all',
     ],
+    [
+      'href' => 'https://example.com/css?family=Open+Sans',
+      'media' => 'all',
+    ],
   ]));
   return $response;
 }
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php
index 969e7cc8671e836035e74c27f54576e996acdfd6..6010186c0b7d4bdd13d912f487f60027e3d63f6a 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php
@@ -38,6 +38,8 @@ public function testAjaxCommands() {
     // Tests the 'add_css' command.
     $page->pressButton("AJAX 'add_css' command");
     $this->assertWaitPageContains('my/file.css');
+    $this->assertSession()->elementExists('css', 'link[href="my/file.css"]');
+    $this->assertSession()->elementExists('css', 'link[href="https://example.com/css?family=Open+Sans"]');
 
     // Tests the 'after' command.
     $page->pressButton("AJAX 'After': Click to put something after the div");