Skip to content

Make a sticky preference for single-page vs. multi-page views#694

Open
gibson042 wants to merge 5 commits intotc39:mainfrom
gibson042:gh-631-sticky-multipage
Open

Make a sticky preference for single-page vs. multi-page views#694
gibson042 wants to merge 5 commits intotc39:mainfrom
gibson042:gh-631-sticky-multipage

Conversation

@gibson042
Copy link
Copy Markdown
Member

@gibson042 gibson042 commented Apr 20, 2026

Fixes #631

Expose buttons in the shortcuts popup for setting a localStorage "multipagePreference" entry to either empty or "single-page" or "multi-page" (and a way for similar data-multipage-preference="…" controls to be embedded in documents, necessary for mobile and other keyboard-free interactions), and check for that preference when loading any page to perform a prompt redirect if needed (e.g., before loading an entire single-page spec).

Redirects are not applied when following internal links, so using toggling between single-page and multi-page views without changing the preference still works.

@michaelficarra
Copy link
Copy Markdown
Member

I don't like this. I prefer using the single-page document. When I open https://tc39.es/ecma262 in a new tab, I want to stay in the single-page document. But when I click a link that somebody posts to the multipage document, I am fine with it loading the multipage document. And when I want to share a link with somebody, I sometimes switch to the multipage document to copy the URL. But I don't want to go to the multipage document the next time I load the spec. For the latter problem, I could see adding a "copy multipage document link to clipboard" keyboard shortcut, but I don't know if there's a solution to the former problem.

@gibson042
Copy link
Copy Markdown
Member Author

I don't like this. I prefer using the single-page document. When I open https://tc39.es/ecma262 in a new tab, I want to stay in the single-page document. But when I click a link that somebody posts to the multipage document, I am fine with it loading the multipage document. And when I want to share a link with somebody, I sometimes switch to the multipage document to copy the URL. But I don't want to go to the multipage document the next time I load the spec. For the latter problem, I could see adding a "copy multipage document link to clipboard" keyboard shortcut, but I don't know if there's a solution to the former problem.

Could you further elaborate upon "the former problem"? When following a link to the multi-page document, are you fine with loading the multi-page resource, or are you insisting upon that? And for links to the single-page document, would you likewise insist upon loading that rather than redirecting per preference to the multi-page document? Because if not, then it seems like either the first problem collapses into the second1 or that you want the preference to asymmetrically affect only requests for the single-page document2, but if you would insist upon loading the single-page document then it seems like you reject at least part of #631 and I'd like to explore that.

Footnotes

  1. solved by e.g. single-page vs. multi-page permalink access and/or a more explicit way to set the preference

  2. which is certainly possible, but less friendly to those with a single-page preference

@bakkot
Copy link
Copy Markdown
Member

bakkot commented Apr 20, 2026

I would prefer links to the single-page document always open as single-page and links to the multi-page document always open as multi-page. Also, like @michaelficarra I regularly toggle between the two for the purposes of sharing links or find-on-page, without that indicating a preference about how future pages should be opened. I'm OK with having some sort of setting for "would you like to override opened links to force one state or the other", but I don't think it is appropriate for merely switching between the two states to be taken to indicate such a preference.

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Apr 20, 2026

I only ever want the single-page version, but I agree with #694 (comment)

@gibson042
Copy link
Copy Markdown
Member Author

I would prefer links to the single-page document always open as single-page and links to the multi-page document always open as multi-page. Also, like @michaelficarra I regularly toggle between the two for the purposes of sharing links or find-on-page, without that indicating a preference about how future pages should be opened. I'm OK with having some sort of setting for "would you like to override opened links to force one state or the other", but I don't think it is appropriate for merely switching between the two states to be taken to indicate such a preference.

Thanks, that's useful feedback. How would y'all feel about the preference being set from About this Specification, such that the experience of updating it is something like "scroll/navigate to the start of the spec and then click as appropriate to set the preference and reload"? Maybe buttons that are enabled in correspondence with localStorage?

This document is available as a single page and as multiple pages. You can set a permanent preference for which view to use: No preference or Always single-page or Always multi-page.

It could also be added to the keyboard shortcuts popup for convenience, but that's too difficult to access on mobile so it couldn't live only there... and I'm inclined to leave it out.

@gibson042 gibson042 force-pushed the gh-631-sticky-multipage branch from 8ef1dc1 to 1d7fa54 Compare April 20, 2026 20:33
@bakkot
Copy link
Copy Markdown
Member

bakkot commented Apr 20, 2026

WFM. I'd also put it in the shortcuts menu personally but don't feel strongly.

@gibson042
Copy link
Copy Markdown
Member Author

I have made the change to set the preference only by direct interaction with elements explicitly marked for that purpose.

@michaelficarra
Copy link
Copy Markdown
Member

What happens when you press m while one of these options is selected? Does it navigate you away and right back? Does it do nothing? Does it change your preference?

I'm still not convinced by the utility of this feature. If it stays completely out of the way of my workflow and the workflows of consumers who don't use it, I don't have much standing to object to it, but at this point I still don't see the point of it.

@gibson042
Copy link
Copy Markdown
Member Author

What happens when you press m while one of these options is selected? Does it navigate you away and right back? Does it do nothing? Does it change your preference?

As requested above, there is no change in what happens when you press m—it toggles the view without touching the preferences, allowing you to freely bounce between single-page and multi-page with no effect on future visits.

I'm still not convinced by the utility of this feature. If it stays completely out of the way of my workflow and the workflows of consumers who don't use it

It does; anyone who leaves the preference unset will have no change in experience.

I don't have much standing to object to it, but at this point I still don't see the point of it.

The point is to improve the experience for anyone who does have a preference, particularly on mobile devices which often have limited resources and are effectively precluded from using keyboard shortcuts.

@gibson042 gibson042 changed the title Make multipage a sticky preference Make a sticky preference for single-page vs. multi-page views Apr 21, 2026
@michaelficarra
Copy link
Copy Markdown
Member

As requested above, there is no change in what happens when you press m—it toggles the view without touching the preferences, allowing you to freely bounce between single-page and multi-page with no effect on future visits.

Doesn't that kind of violate the preference?

The point is to improve the experience for anyone who does have a preference, particularly on mobile devices which often have limited resources and are effectively precluded from using keyboard shortcuts.

Since the redirect happens client-side, following a link to the single-page document will still load the single-page document before the multi-page one, actually increasing data use. Perhaps setting a cookie so the server could 302/307 to the appropriate page would be a better implementation if that's the goal.

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Apr 21, 2026

the server is github pages, there's no logic that can run there.

@michaelficarra
Copy link
Copy Markdown
Member

I'm just talking about ideals.

@gibson042
Copy link
Copy Markdown
Member Author

gibson042 commented Apr 21, 2026

As requested above, there is no change in what happens when you press m—it toggles the view without touching the preferences, allowing you to freely bounce between single-page and multi-page with no effect on future visits.

Doesn't that kind of violate the preference?

No, we're treating m as an explicit signal to interact in a specific mode regardless of preference (#694 (comment) : "I regularly toggle between the two for the purposes of sharing links or find-on-page, without that indicating a preference about how future pages should be opened").

The point is to improve the experience for anyone who does have a preference, particularly on mobile devices which often have limited resources and are effectively precluded from using keyboard shortcuts.

Since the redirect happens client-side, following a link to the single-page document will still load the single-page document before the multi-page one, actually increasing data use.

It will load part of the single-page document, and then abort to load the multi-page document ASAP (because the first requested external resource is multipage.js via a <script> element with attribute async). For ECMA-262, overall data use will be lower than loading the single-page document (and likewise with respect to consumption of other resources such as memory and time).

Perhaps setting a cookie so the server could 302/307 to the appropriate page would be a better implementation if that's the goal.

ecmarkup produces content to be served from many places, and cannot rely upon server-side support (which in practice is effectively limited to static content anyway—neither ECMA nor GitHub are likely to open up cookie-based server-side redirection). And to be clear, the goal is practical improvement for ECMA-262 without being so narrow that it doesn't also apply to other documents availing theirselves of multipage support.

@gibson042 gibson042 requested review from bakkot and michaelficarra May 3, 2026 18:11
gibson042 added 3 commits May 3, 2026 14:21
Fixes tc39#631

Set a localStorage "preferMultipage" entry to either "true" or "false" when
toggling multipage, and check for it when loading any page to perform a prompt
redirect if needed (e.g., before loading an entire single-page spec).
...for keyboard-free interactions (e.g., mobile)

Example HTML:
* `<a href="multipage/" data-prefer-multipage="true">...</a>`
* `<label><input type="radio" name="prefer-multipage" data-prefer-multipage="false"> Single-page</label>`
...identified by attribute "data-multipage-preference" with value "" or
"single-page" or "multi-page"
@gibson042 gibson042 force-pushed the gh-631-sticky-multipage branch from b0ee6f7 to b8163d1 Compare May 3, 2026 18:21
@gibson042 gibson042 force-pushed the gh-631-sticky-multipage branch from 68761c6 to 37d572c Compare May 3, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multipage should be more accessible

4 participants