Skip to content

Refactor default.js

Sarah German requested to merge default-js-refactor into main

What does this MR do and why?

Refactors default.js, which had gotten a little unorganized as we've added more site-wide Vue components. This file is used to load components and functions that are used on all standard content pages.

Changes:

  • Removes the Archives page component from default.js. It does not need to load site-wide; we can load it solely on the archives page.
  • Removes extra event listeners on DOMContentLoaded. Mounting the various components can happen within a single event listener.
  • Removes Vue library imports from individual components in favor of a globally-included Vue import and assignment to the window scope in default.js. We were previously loading Vue itself twice on the deprecations and archives pages (which wasn't as heavy as you might think, but still... oops).

This MR may provide minor frontend performance improvements as it should reduce bundle size on some pages, but the intent here is mostly to make this code more readable and extendable without unnecessary repetition. I'd started to include these changes in work for #1515 (closed), but it got a little far-reaching, so I figured a separate refactor MR like this would be easier to review.

Screenshots, screen recordings, or links to review app

No visual changes expected.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md.
  2. Verify components referenced in this MR still load without errors:

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah German

Merge request reports