Sloth is a Chromium extension that ensures that tabs are lazily loaded. That is, when the browser starts, tabs from the previous session are not loaded immediately. They are loaded only when the user clicks on the tab (or somehow activates the tab). This speeds up the browser tremendously when there are lot of tabs open.
Sloth by default tries hard to ensure that no tabs are loaded. To prevent the last active tab from loading, Sloth creates a new empty tab and focusses it.
However, this behavior may not be suitable for everyone. Users had requested that this feature be made optional.
Hence, I added an options page to Sloth, with a toggle for enabling / disabling the "new tab feature":
Asynchronous storage and Sloth
Adding the options page for Sloth was not trivial. Unlike other extensions Sloth has some special needs.
Sloth has to kick-in and do its magic when the browser is still starting. That means, as quick as possible and in the on-start handler. However, the recommended "options" storage for Chromium has an Asynchronous API. That means the storage can only be accessed outside of the "on-start" handler.
To solve this problem, I used the
localStorage API, instead of the default
chrome.storage API. The
localStorage API has a synchronous API and hence suitable for Sloth.
Installation is easier now
Since the time of my last update here, I have published the extension on the Chrome Store here. There are quite a few users already and nobody has complained so far, so I suppose the extension is working for them! If you try it, let me know how it goes in the comments below.
Note: The changes described here are live as part of the v0.2 release.
Posted on Utopian.io - Rewarding Open Source Contributors