As a reader, I would like to have a persistent state for my sidebar, so that I don't have to change the state every time I navigate to a new article.
Generally, we advise against any sort of inline JS in Wikimedia products, as JS is executed on all browsers (even incompatible unsupported browsers), JS errors there can break site functionality and due to our caching infrastructure are difficult to rectify.
We instead decided to make this logged in only as part of T255727.
Inline JS solution (for prosperity)
The following patch demonstrates the localStorage and inline JS approach:
Prerequisite: T257075: Simplify the checkboxHack API
- The setting is stored client-side in the browser's LocalStorage service.
- The setting is loaded right before the sidebar is rendered, thus avoiding an initial flicker if the sidebar would be shown and then immediately hidden.
- The sidebar is rendered and the setting loaded after the content is loaded, therefore the initial render of the above-the-fold content (first page) is not delayed by initializing the sidebar. That delay is barely measurable anyway.