dojo.provide

Project owner:?–
Available:since V?

dojo.provide is a core part of the dojo module system. It tells the loader that a specific module has been loaded.

Introduction

Each javascript source file must have at least one dojo.provide() call at the top of the file, corresponding to the file name. For example, js/dojo/foo.js must have dojo.provide(“dojo.foo”); before any calls to dojo.require() are made.

Usage

dojo.provide is an integral part of Dojo’s module system and its loader. dojo.provide() tells the loader that the a module has been provided for the given name. It also creates a JavaScript object for the name.

This code example is for a my/module.js file. Note the convention of placing the dojo.provide call before dojo.require calls.

1
2
3
4
5
6
7
8
9
<script type="text/javascript">
  dojo.provide("my.module");

  dojo.require("dojo.io.script");

  //dojo.provide made sure that my.module was created as a JavaScript object,
  //so properties can be assigned to it:
  my.module.name = "my module";
</script>

Multiple dojo.provide calls can live in a file, but outside of built layer, it is normal just to see one for the module that matches the file name.

Error in the documentation? Can’t find what you are looking for? Let us know!