Skip to content

Commit 6ea383f

Browse files
committed
Twenty Twenty-One: Add nav menu toggle behaviors at DOMContentLoaded instead of at the load event.
The `load` event (on `window`) fires after all resources on a page have been loaded, including images. This means that on a slow connection, the mobile nav menu button may be rendered yet unresponsive to taps between when it first appears and when the page has fully loaded. This is rectified by switching to the `DOMContentLoaded` event so that the nav menu behaviors are attached as soon as the DOM has fully loaded. Props gernberg, westonruter, sabernhardt. Fixes #63613. git-svn-id: https://develop.svn.wordpress.org/trunk@60352 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 40bc4f5 commit 6ea383f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/wp-content/themes/twentytwentyone/assets/js/primary-navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function twentytwentyoneExpandSubMenu( el ) { // jshint ignore:line
211211
} );
212212
};
213213

214-
window.addEventListener( 'load', function() {
214+
document.addEventListener( 'DOMContentLoaded', function() {
215215
new navMenu( 'primary' );
216216
} );
217217
}() );

0 commit comments

Comments
 (0)