Moving JS to external file to eliminate duplication.