moved javascript blcks to <head> of html templates