diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index a82353d..bd7f39f 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -666,7 +666,12 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
     $settings['ajaxPageState']['theme'] = $theme_key;
     // Checks that the DB is available before filling theme_token.
     if (!defined('MAINTENANCE_MODE')) {
-      $settings['ajaxPageState']['theme_token'] = \Drupal::csrfToken()->get($theme_key);
+      // The theme token is only validated when the theme requested is not the
+      // default, so don't generate it unless necessary.
+      // @see \Drupal\Core\Theme\AjaxBasePageNegotiator::determineActiveTheme()
+      if ($theme_key !== $this->configFactory->get('system.theme')->get('default')) {
+        $settings['ajaxPageState']['theme_token'] = \Drupal::csrfToken()->get($theme_key);
+      }
     }
 
     // Provide the page with information about the individual asset libraries
