diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-05-05 20:19:40 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-05-05 20:19:40 +0200 |
| commit | 87b6326d672f5d40b14460bdedebf4f69288fb6a (patch) | |
| tree | 39accf7138d1c7b72f18d2c901e1d38c67bc3a00 | |
| parent | 12d3f107c1634ed41a800e220ccf99b665d906d8 (diff) | |
| download | rust-87b6326d672f5d40b14460bdedebf4f69288fb6a.tar.gz rust-87b6326d672f5d40b14460bdedebf4f69288fb6a.zip | |
Improve settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 3 | ||||
| -rw-r--r-- | src/librustdoc/html/static/js/settings.js | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 1dfd9c762c4..a6b64cd54af 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -303,6 +303,9 @@ function loadCss(cssFileName) { getSettingsButton().onclick = event => { event.preventDefault(); + // Sending request for the CSS and the JS files at the same time so it will + // hopefully be loaded when the JS will generate the settings content. + loadCss("settings"); loadScript(window.settingsJS); }; diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 43b24245ab2..ac483dbb419 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -3,7 +3,7 @@ /* eslint prefer-const: "error" */ /* eslint prefer-arrow-callback: "error" */ // Local js definitions: -/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme, loadCss */ +/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme */ /* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */ /* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */ @@ -207,9 +207,6 @@ }, ]; - // First, we add the settings.css file. - loadCss("settings"); - // Then we build the DOM. const el = document.createElement("section"); el.id = "settings"; |
