Extract message js behavior to common file