Follow up to T393540 and T381574.
It'd be nice to fold all references by default on page load, so that users don't need to remember or type the keyboard shortcut (Ctrl-Alt-, or Cmd-Alt-, on Mac). The reason this is desirable is that references can consume large amounts of the visible wikitext in mainspace articles on encyclopedic projects like Wikipedia. From a visual standpoint, it's almost better to just always fold references, provided we can still search within them (which we can). Some users will not want this behaviour, and the potential performance cost of scanning the whole page is not something we want to force on anyone, so we could make this available as a default-off preference.
Later, we might consider adding a button to the WikiEditor "Advanced" toolbar so that users can selectively (re-)fold all ref tags on demand.
In initial tests, it seems this performs pretty well and will almost always finish within a second. If it doesn't, we can silently fail and fallback to the standard behaviour of only folding refs within the known syntax tree.