Move Javascript code for triggers to a separate file