JavaScript dependency injection