diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 1dfd9c762c46e..667f89c07e212 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -7,6 +7,8 @@
/* global onEach, onEachLazy, removeClass */
/* global switchTheme, useSystemTheme */
+"use strict";
+
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
@@ -292,15 +294,12 @@ function loadCss(cssFileName) {
}
(function() {
- "use strict";
-
function loadScript(url) {
const script = document.createElement('script');
script.src = url;
document.head.append(script);
}
-
getSettingsButton().onclick = event => {
event.preventDefault();
loadScript(window.settingsJS);
diff --git a/src/librustdoc/html/static/js/scrape-examples.js b/src/librustdoc/html/static/js/scrape-examples.js
index 491b3950ae6eb..70fcef522129e 100644
--- a/src/librustdoc/html/static/js/scrape-examples.js
+++ b/src/librustdoc/html/static/js/scrape-examples.js
@@ -4,6 +4,8 @@
/* eslint prefer-arrow-callback: "error" */
/* global addClass, hasClass, removeClass, onEachLazy */
+"use strict";
+
(function () {
// Number of lines shown when code viewer is not expanded
const MAX_LINES = 10;
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 60ad431ba7a99..54ce2508c468d 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -5,7 +5,9 @@
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
-(function () {
+"use strict";
+
+(function() {
// This mapping table should match the discriminants of
// `rustdoc::formats::item_type::ItemType` type in Rust.
const itemTypes = [
diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js
index 43b24245ab2e8..119d4b07665a4 100644
--- a/src/librustdoc/html/static/js/settings.js
+++ b/src/librustdoc/html/static/js/settings.js
@@ -7,6 +7,8 @@
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
+"use strict";
+
(function () {
const isSettingsPage = window.location.pathname.endsWith("/settings.html");
diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js
index 290bf40a8f577..f788d41d2ded4 100644
--- a/src/librustdoc/html/static/js/source-script.js
+++ b/src/librustdoc/html/static/js/source-script.js
@@ -9,7 +9,10 @@
// Local js definitions:
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global updateLocalStorage */
-(function () {
+
+"use strict";
+
+(function() {
function getCurrentFilePath() {
const parts = window.location.pathname.split("/");
diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js
index 913fc278eb387..052731e99aed2 100644
--- a/src/librustdoc/html/static/js/storage.js
+++ b/src/librustdoc/html/static/js/storage.js
@@ -3,6 +3,8 @@
/* eslint prefer-const: "error" */
/* eslint prefer-arrow-callback: "error" */
+"use strict";
+
const darkThemes = ["dark", "ayu"];
window.currentTheme = document.getElementById("themeStyle");
window.mainTheme = document.getElementById("mainThemeStyle");