Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

requirejs vs google javascript closure dependency management

I've been using the google javascript closure library for a variety of components, and I've also used its dependency management. I'm curious as to how that compares to using requirejs for dependency management. Specifically, is there a particular reason to choose one over the other?

If I'm using the google closure library, would there be a logical reason to use requirejs to manage dependencies vs using the closure dependency management? Are there standards that requirejs follows that closure does not?

like image 460
Jeff Storey Avatar asked Dec 16 '12 15:12

Jeff Storey


1 Answers

The Closure Library dependency management is intended to be provide an ordering of files to resolve dependencies and are removed by the Closure Compiler during compilation (rewritten as necessary to provide the namespaces as needed, actually). While the compiler has some experimental compile time support for AMD modules, they still need some work on the type checking front in particular to be a full replacement for Closure's goog.require. Even when compiler support is sufficient, goog.require does not require a full parse of the JS in order to do dependency management (I'm not familiar enough with RequireJS to know if this is the case) and so for large projects with many optional files goog.require are currently much more efficient.

like image 147
John Avatar answered Oct 26 '22 23:10

John