I was planning to build it with ultralig.ht, but I'm not 100% sure if it's ready for it. But since most of the content I'm interested in for research is textual/reader mode, and the rest can be viewed with yt-dlp, I think it can render them and it seems the lightest weight. Otherwise it's webkit or servo that I could think of for this.
Good to know there's interest in this.
If your code would misbehave outside a certain range of values and you're input might span a larger range, you should be checking your input against the range that's valid. Your sample code simply doesn't do that, and that's why there's a bug.
That the bug happens to involve a timer is irrelevant.