Search code examples
javascriptgoogle-closuregoogle-closure-library

Google-closure : What's the difference between Goog.provide vs Goog.require


Can anyone tell me the difference. I've just started google-closure.


Solution

  • goog.provide creates a namespace; goog.require "imports" code from a given namespace so the closure compiler can find it.

    Typically when you create a class, you'll provide a namespace for it, and require all of the namespaces that your classes uses directly.

    More info (and examples) here: https://developers.google.com/closure/library/docs/tutorial