Skip To ContentArcGIS for DevelopersSign In Dashboard


require(["esri/core/requireUtils"], function(requireUtils) { /* code goes here */ });
Object: esri/core/requireUtils
Since: ArcGIS API for JavaScript 4.3

Provides a convenience function that allows you to dynamically load required modules.

Method Overview

NameReturn TypeSummaryObject

Deprecated in favor of promiseUtils.create().

more details
more detailsrequireUtils

Method Details

when(moduleRequire, moduleNames){Promise}static
  • since version 4.10

Deprecated in favor of promiseUtils.create(). Dynamically requires one or more modules and returns a promise that resolves when all the specified modules have loaded.

moduleRequire require

The require function used to load the modules. This is the AMD alias (e.g. the moduleRequire reference in the snippets below) used to reference the require module.

moduleNames String[]|String

The names of the modules to load.

PromiseA promise which resolves with an array containing the loaded modules, or a single module when moduleNames is a string.
// Load multiple modules conditionally
// like this starting at 4.10
], function( promiseUtils ) {
  // load modules based on whether a user selects
  // a UI option to apply class breaks to a layer
  if (classBreaksSelected) {
    return promiseUtils.create(function(resolve, reject) {
      require([ "esri/renderers/ClassBreaksRenderer" ], resolve);
    }).then(function(ClassBreaksRenderer) {
      // Create renderer and apply it to the desired layer

// Load a single module conditionally
 ...  // load other modules as needed
 ], function(..., requireUtils, moduleRequire) {
  if (basemapUrl && view) {
    // if basemapUrl is provided then
    // load customBasemap module and set up and
    // custom basemap with provided layers.
    requireUtils.when(moduleRequire, "./customBasemap")
     .then(function(Basemap) {
       var customBasemap = new Basemap({
         baseLayers: [layers],
         title: "Custom Basemap",
         id: "myBasemap"

API Reference search results