ParentFull threadchucksmash·JSNice[1] is an academic project that did a pretty good job of this in the 2010s and they give some pointers on how it is accomplished[2].[1]: http://jsnice.org/[2]: https://www.sri.inf.ethz.ch/jsniceView on HN