OJS 2.4.8: Custom theme loading in too slow?

I’ve been wokring on creating a new theme for OJS website. I changed some of the .tpl templates added few lines of javascript and created a css file that’s loaded in inside the ThemePlugin class. Now the problem I have is that whenever the site gets loaded in I can see old theme for a second or so before it changes back to the correct one. Here’s how it looks just before it switches to the “correct” theme: https://i.imgur.com/9jBdpqK.png

The theme itself after that works fine but the old theme appears every time you load a page on the website. I tried removing the javascript I added in case that was slowing it down but the problem was still there. Any ideas on what I should try to get rid of that screen appearing? (I’m doing all of this on a localhost if it matters)