Move JS code from index into script file.