Skip to content

Commit cd6e683

Browse files
committed
doc: defer script loading
1 parent e23f274 commit cd6e683

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

doc/api_assets/api.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ function setupStickyHeaders() {
118118
).observe(header);
119119
}
120120

121-
// Check if we have JavaScript support
122-
document.querySelector(':root').classList.add('has-js');
121+
document.addEventListener('DOMContentLoaded', function() {
122+
// Check if we have JavaScript support
123+
document.querySelector(':root').classList.add('has-js');
123124

124-
// Restore user mode preferences
125-
setupTheme();
125+
// Restore user mode preferences
126+
setupTheme();
126127

127-
// Handle pickers with click/taps rather than hovers
128-
setupPickers();
128+
// Handle pickers with click/taps rather than hovers
129+
setupPickers();
129130

130-
// Track when the header is in sticky position
131-
setupStickyHeaders();
131+
// Track when the header is in sticky position
132+
setupStickyHeaders();
133+
}, { once: true });

doc/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ <h1>Node.js __VERSION__ documentation</h1>
7474
</div>
7575
</div>
7676
</div>
77-
<script src="assets/api.js" type="text/javascript"></script>
77+
<script defer src="assets/api.js" type="text/javascript"></script>
7878
</body>
7979
</html>

0 commit comments

Comments
 (0)