re-implement dynamic insert of script and links