move inline JS to external JS file; better escaping
strip extraneous whitespace