Skip to content

Move initTopNav to DOMContentLoaded

What does this MR do?

For the top nav redesign, the call to initTopNav which bootstraps the top Menu dropdown was originally placed in deferredInitialisation. Based on the title of the commit message which introduced this pattern, it's possible that initTopNav should belong in the DOMContentLoaded callback since it's a frequently used above-the-fold component.

Pros to moving this to DOMContentLoaded:

  1. It's no longer dependent on the critical path before it. In this MR it was identified that an unrelated JavaScript error could prevent the top nav from being loaded.
  2. It should be ready sooner.
  3. It is async so it shouldn't block anything else from loading.

Cons to moving this:

  1. It might kick off network requests/processes which could consume resources while the rest of DOMContentLoaded tries to load.

Screenshots (strongly suggested)

  • To test, you'll want to enable the :combined_menu feature flag
Still works
Screen_Shot_2021-05-24_at_8.19.51_PM

Merge request reports