The startup hit to restore the tabs, really spins up my system.
Unfortunately this is essentially unavoidable.
I have an extension which Lazy-Loads new tabs by creating a data-uri which will redirect to the desired URL when the tab is focused, so my first plan was to capture tabs loading at startup and create a similar data-uri for each one rather than letting them load. As an example, this tab currently registers as 90Mb, whereas a data-uri from my extension is only 18Mb. But that plan didn’t work because programatically setting an existing tab’s url to a data-uri is prevented as a security policy.
An alternative to using a data-uri would be to have the tab load a page from the extension, and have that page load the proper URL when the tab is activated. However, this would not sync properly to a mobile device which doesn’t have the extension installed. It would also need a workaround to avoid data loss, because the tabs would be closed when the extension is updated.
Another way would be to store the titles and urls of the entire tab set every time a tab is opened, closed or navigated to a new url. This could be used to detect when tabs are being reloaded at startup, and each tab could be closed and replaced with a data-uri as mentioned above. But there’s a lot of complexity in this, and it would mean the user loses everything that was in the Back Button of each tab in the previous session.
So the only viable way to do it via an extension is to let each tab load, and then set them to be Discarded. If the CPU cycles of the loading tabs are an issue then the fix would have to be within the browser, not an extension. There’s already an issue raised, which you can Star: https://issues.chromium.org/issues/41483135
The algorithm I used in my extension is as follows:
When a tab is created with a status of “unloaded,” store its ID.
When a tab reaches a status of “complete” and its ID has been stored, suspend the tab.
Edit: here’s a bug report from 2022 which got ignored for so long it was closed, so don’t expect anything to happen on this issue. The reporter had 5971 tabs open in 3 windows!
https://issues.chromium.org/issues/40861830