File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ // The regular theme-switch.js script runs in the header and blocks the initial
4
+ // page render to prevent flickering. The following code cannot run as part of
5
+ // that, because the page must have been rendered first.
6
+
7
+ // close the theme dropdown if clicking somewhere else
8
+ document . querySelector ( '.theme-icon' ) . onblur = handleBlur ;
9
+
10
+ // show the theme selector only if JavaScript is enabled/available
11
+ document . querySelector ( '.theme-icon' ) . style . display = 'block' ;
Original file line number Diff line number Diff line change @@ -60,9 +60,6 @@ function setThemeToSystemPref() {
60
60
}
61
61
}
62
62
63
- // close the theme dropdown if clicking somewhere else
64
- document . querySelector ( '.theme-icon' ) . onblur = handleBlur ;
65
-
66
63
// Check for saved user preference on load, else check and save user agent prefs
67
64
let savedTheme = null ;
68
65
if ( storageAvailable ( "localStorage" ) ) {
@@ -73,6 +70,3 @@ if (savedTheme) {
73
70
} else {
74
71
setThemeToSystemPref ( ) ;
75
72
}
76
-
77
- // show the theme selector only if JavaScript is enabled/available
78
- document . querySelector ( '.theme-icon' ) . style . display = 'block' ;
Original file line number Diff line number Diff line change 36
36
37
37
<!-- atom -->
38
38
<link type =" application/atom+xml" rel =" alternate" href =" https://blog.rust-lang.org/{{ blog.prefix }} feed.xml" title =" {{ blog.title }} " />
39
+
40
+ <!-- theme switcher -->
41
+ <script src =" {{ root }} scripts/theme-switch.js" ></script >
Original file line number Diff line number Diff line change 20
20
<li class =" theme-item" onclick =" changeThemeTo('system');" >System</li >
21
21
</ul >
22
22
</button >
23
- <script src =" {{ root }} scripts/theme-switch.js" ></script >
23
+ <script src =" {{ root }} scripts/theme-switch-post .js" ></script >
24
24
</ul >
25
25
</nav >
You can’t perform that action at this time.
0 commit comments