Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 87b6326

Browse files
Improve settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections
1 parent 12d3f10 commit 87b6326

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/librustdoc/html/static/js/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ function loadCss(cssFileName) {
303303

304304
getSettingsButton().onclick = event => {
305305
event.preventDefault();
306+
// Sending request for the CSS and the JS files at the same time so it will
307+
// hopefully be loaded when the JS will generate the settings content.
308+
loadCss("settings");
306309
loadScript(window.settingsJS);
307310
};
308311

src/librustdoc/html/static/js/settings.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* eslint prefer-const: "error" */
44
/* eslint prefer-arrow-callback: "error" */
55
// Local js definitions:
6-
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme, loadCss */
6+
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme */
77
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
88
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
99

@@ -207,9 +207,6 @@
207207
},
208208
];
209209

210-
// First, we add the settings.css file.
211-
loadCss("settings");
212-
213210
// Then we build the DOM.
214211
const el = document.createElement("section");
215212
el.id = "settings";

0 commit comments

Comments
 (0)