JavaScript dependency injection helper