Skip to content

Commit

Permalink
doc: defer script loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Mar 18, 2022
1 parent e23f274 commit cd6e683
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions doc/api_assets/api.js
Expand Up @@ -118,14 +118,16 @@ function setupStickyHeaders() {
).observe(header);
}

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

// Restore user mode preferences
setupTheme();
// Restore user mode preferences
setupTheme();

// Handle pickers with click/taps rather than hovers
setupPickers();
// Handle pickers with click/taps rather than hovers
setupPickers();

// Track when the header is in sticky position
setupStickyHeaders();
// Track when the header is in sticky position
setupStickyHeaders();
}, { once: true });
2 changes: 1 addition & 1 deletion doc/template.html
Expand Up @@ -74,6 +74,6 @@ <h1>Node.js __VERSION__ documentation</h1>
</div>
</div>
</div>
<script src="assets/api.js" type="text/javascript"></script>
<script defer src="assets/api.js" type="text/javascript"></script>
</body>
</html>

0 comments on commit cd6e683

Please sign in to comment.