Fix JS error when loading too early