Attach javascript to the end of the widget if there is a javascript template.