Extract js into template