Fixes problems with loading JS before html loaded