Skip to content

Make the background script insert custom CSS #72

@astral-sa

Description

@astral-sa

A lot of the javascript logic, preference checking, and expensive individual element style setting that executes every page load (for every post) can be converted to some CSS that we generate once in the background page and insert into tabs as necessary with tabs.insertCSS().

Ideally I'd like to configure the background page to be persistent rather than event (event pages aren't even supported on Firefox, so on Firefox it's already persistent). It may even be acting as persistent on Chrome with the way it's listening for messages. If we make the background page officially persistent, it could generate the CSS once on extension load (and, subsequently, if any preference that would affect styles is modified in the settings) and keep a copy of it in memory. Then, when an SA forum page is loaded, it can inject the relevant CSS immediately. There would be separate CSS sets for different forum contexts (showthread and forumdisplay+usercp would be the two main ones)

Another option could be to store the computed CSS strings somewhere else, perhaps storage.local, but there it would count against the 5MB limit and have to get loaded out of storage each page load, which would slow things down somewhat.

Yet another option is for the background page to compute it on page load, but this, too, is less than ideal.

This feature will also helpfully reduce the amount of stuff that needs to be converted from jQuery in the main part of the extension. It will make things nicer for the users with SALR's style changes applying more quickly and with fewer reflows. The result of this feature will be most noticeable for options like thread highlighting where a lot of CSS is applied.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions