javascript optimization and documentation