1.

What Is Config Function?

Answer»

The Require JS can be initialized by passing the main configuration in the HTML template through the data-main attribute.

If you want to update the Require JS configuration values with your own configurations value. You can do USING the require js. Config FUNCTION.

The configurations options:-

  • config - This is for configuration to a module by using the config option
  • baseUrl -This is the root path to start the loading of modules.
  • paths - this is the path mapping for modules that don’t EXISTS in under the base URL.
  • Shims - This is use for configuration for dependencies.
  • deps - array of dependencies to load
  • url Args -This is the QUERY string arguments are used to FETCH all resources that are loaded by using Require JS.
  • callback -It executes a function after loading the dependencies and is required when Require is specified as config object before loading Require JS.
  • xhtml - It is used to create the script elements by using the document.createElement() method.
  • script Type - It defines the value for script type attribute used in the document. Default type is "text/javascript".

Example looks like:-

require.config({

baseUrl: 'scripts/app',

paths: {

lib: '../lib'

},

shim: {

'backbone': {

deps: ['underscore'],

exports: 'Backbone'

}

}

});

The Require JS can be initialized by passing the main configuration in the HTML template through the data-main attribute.

If you want to update the Require JS configuration values with your own configurations value. You can do using the require js. Config function.

The configurations options:-

Example looks like:-

require.config({

baseUrl: 'scripts/app',

paths: {

lib: '../lib'

},

shim: {

'backbone': {

deps: ['underscore'],

exports: 'Backbone'

}

}

});



Discussion

No Comment Found