GitHub had to solve the same problem when speeding up there code viewer.
https://github.blog/engineering/architecture-optimization/cr...