Run scripts only when necessary (fixes JS errors)