Put dynamic Javascript in header after doing operations

Put dynamic Javascript in header after doing operations