Open sacrael opened 3 years ago
Not to disagree with you on your suggestion, but the current implementation of the word replacement is not final. Currently the issue has been getting the page to replace every instance of a word from the dictionary (See issue #22). With that fix there will be a major improvement for the word replacement as it will eliminate the need for the innermost for loop and replace it with a function of constant speed (i.e. dictionary lookup).
This isn't to say that making a service worker is a bad idea, I just don't know if we should do it while we don't know how fast it will run when we get it to work like we wanted it too.
Currently, in the backend, the word processing is done on each page load within the thread of the active tab. After running multiple benchmarks on decently-sized Wikipedia pages, the average page load time is ~8 seconds, with ~70% of that time being spent in the word replace function.
To alleviate the workload of the word replace, we can leverage an external thread to handle the "Spoiler Blocking" tasks by creating a service worker.
Below is a design of the new backend structure:
This should provide better page performance by freeing up the user interface thread and serve the page changes as they are processed one by one.