extract the common javascript out into a separate file