After some tweaking, I found out that if I create HTML on a temporary variable and do a single innerHTML call at the end is significantly faster than calling innerHTML on every little piece of HTML code that I want to add. This simple change improved my code from 1800 ms to 25 ms, what a big difference!