Library javascript generation

Move constants for better reuse