Open Bug 1880897 Opened 7 months ago Updated 1 month ago

[meta] browser.js is too big, a potpourri of things that would be better off elsewhere, and some of it badly architectured

Categories

(Firefox :: General, task, P3)

Desktop
All
task

Tracking

()

People

(Reporter: Gijs, Unassigned)

References

(Depends on 5 open bugs)

Details

(Keywords: meta)

Previously: bug 758812. From there:

It is widely acknowledged that browser.js is too damn [big]. The in-tree version is currently 9431 lines long. (It's actually 13,193 lines if you count the 6 files that are already #included)

We're nearly 12 years on, and plus ça change, plus c'est la même chose. We no longer have #includes but we're at 10159 lines, some 300KiB of JS, and people keep adding more!

Besides editing such a huge file (and finding things in it) being annoying, there are some real downsides. Making it smaller and moving things out would mean:

  • Smaller runtime overhead (CPU + memory) for startup, new browser windows, and the hidden window and other windows (which surprisingly also load browser.js!), as we don’t need to load things until used.
  • Finding things is easier for engineers (things have their own file instead of one huge messy one)
  • Better automated tooling support
    • eslint, typescript and other tools would all understand module references better than ones specific to a window global
    • Phabricator will do syntax highlighting again (disabled for large files, browser.js is larger than the threshold)
    • Smaller files mean quicker tool operations

So I'm starting an effort to (a) prevent more code being added to browser.js; (b) refactor the giant pile of code that's already there. I hope to file everything in (b) as "good first" or at least mentored bugs, in order to help move this along.

Depends on: 1880899
Depends on: 1880904
Depends on: 1880913
Depends on: 1880914
Depends on: 1880918
Depends on: 1882774
Depends on: 1882776
Depends on: 1705440
Depends on: 1896764
Depends on: 1597228
Depends on: 1911729
You need to log in before you can comment on or make changes to this bug.