js function to collect scripts on a page