Rearrange javascript in top, bottom static html