move external script dependencies to end of body