Page MenuHomePhabricator

Remove "auto-number headings" preference
Open, MediumPublic

Description

NOTE: removing the preference should only be done after the wikimedia community has been consulted.

Summary:
The "auto-number headings" option severely degrades performance for users who have it enabled and consumes cache capacity for little benefit. The value of the feature, when working as intended, also seems dubious. It is probably best to simply remove the option.

Context:
The "auto-number headings" controls whether section numbers are shown in section headings. The default behavior is to show numbering in the table of contents, but not in the actual section headings.

Problems:
Usually, the HTML generated by the wikitext parser is cached for later re-use. This is done because parsing is relatively slow - depending on the size and complexity of the page, it can take several seconds. However, when the "auto-number headings" option is used, this caching becomes ineffective: since very few people use the option, the chances for a "cache miss" are high (cache fragmentation).

In effect, users that have "auto-number headings" set to a non-standard value are much more likely to hit an uncached page, forcing them to wait until the page has been rendered for them, which may take several seconds depending on the size and complexity of the page. That appears a very high cost for rather little gain.

Usage:
An ad-hoc analysis among users of en.wikipedia.org who have edited in the last 30 days shows that about 0.4% of active editors have the "auto-number headings" option enabled.

Solution:
If there is no great demand for this feature, we should simply remove it. If the feature is to be kept, it should be implemented in CSS: the numbering would always be generated, but the browser would be instructed to not display them. Appropriate CSS rules for showing the numbers could easily be generated from the user settings on the fly. Numbering in ToC would remain.

One possible case for having section numbering would be for print: here the numbers may be useful to find a given section, based on the numbering presented in the table of contents. However, the current behavior is the opposite: for printing, the numbers are hidden from the table of contents as well.

Event Timeline

I support removing many of these rarely used user prefs that cause HTML to vary by these prefs. But, independent of that this one is easily controlled by CSS without modifying the HTML.

Providing the replacement CSS in this task prior to discussion would probably go a long way to making this a gentle change over.

span.tocnumber { display: none; } should do it right?

span.tocnumber { display: none; } should do it right?

Nah, this has to be a misunderstanding. This task has nothing to do with the toc.

Without wpnumberheadings:

Without wpnumberheadings.png (953×1 px, 169 KB)

With wpnumberheadings:

With wpnumberheadings.png (949×1 px, 169 KB)

Yes, instead it'd be:

span.mw-headling-number { display: none; }

… shipped be default to all users, and then over-ridden with a user script using !important or something similarly ghastly.

span.tocnumber { display: none; } should do it right?

Nah, this has to be a misunderstanding. This task has nothing to do with the toc.

Sorry yes .. I mixed up my TOC and section headings. But, looks like @Jdforrester-WMF has me covered. :)

Ah, then there are two implementation paths.

  1. Serve the numbers to everyone with CSS to hide and then users opt in by unhiding.
  2. Let people add numbers with CSS counter.

I was anticipating #2 actually, and I'm pretty sure that would be generally preferable on the MediaWiki side also.

Maybe it's just not used as people aren't aware of this helpful option.

  1. Let people add numbers with CSS counter.

I was anticipating #2 actually, and I'm pretty sure that would be generally preferable on the MediaWiki side also.

It would probably be preferable, but the CSS rules might need to be rather ornate to ensure that subsections/etc are numbered correctly. There's a failure case where the CSS numbering on the heading tag disagrees with the server-side generated numbering (in the TOC).

I'd strongly encourage us to use the same mechanism for both. We can either (a) save some bandwidth on the article page (at the cost of some cached CSS) by using CSS for both the TOC and the heading numbering (with a display: none on the latter or gated on some class on <body> which isn't present by default), or (b) include the numbering from the server on both the TOC and heading, but again with a display: none in the default CSS for the heading.

Option (a) is technically superior, in terms of bandwidth, but (b) may have benefits for accessibility and is probably easier to implement.

Isn't this visible by default?

Cannot reproduce. This is not about the ToC box itself, this is about the headings. (Preferences > Appearance > Advanced Options > Auto-number headings)

Ah, I think the TOC numbering is sufficient.

BPirkle triaged this task as Medium priority.Jun 22 2021, 9:02 PM
BPirkle moved this task from Inbox to Feature Requests to Review on the Platform Engineering board.

One possible way forward might be to combine two approaches: both CSS content and shipping a bit more HTML for all users, but not the whole heading number element. For example, if there would be an attribute data-tocnumber="1.2" on all <hX> tags, then users with this option can be shipped CSS like [data-tocnumber]::before { content: attr(data-tocnumber) ' ' } without the need for any display: none rules for all other readers.

This would also make the whole preference a bit more usable, given that TOC number would not be selectable (hence saving a bit effort for people when trying to get a link to the heading).