Skip to main content

Posts

Showing posts with the label How to Install RequireJS?

What Is config function in RequireJS?

What Is config function? The RequireJS can be initialized by passing the main configuration in the HTML template through the data-main attribute. If you want to update the RequireJS configuration values with your own configurations value. You can do using the requirejs.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 ü    map  - ü    urlArgs -This is the query string arguments are used to fetch all resources that are loaded by using RequireJS. ü    callback -It executes a function after loading the dependencies and is requir...

When Should I use Require() and when to use Define()? [Require vs Define]

The define () method looks like - ü    The define () method is used for facilitating module definition ü    The define () method accepts two optional parameters module ID and array of required modules [dependencies] ü    The define() method MUST return the implementation for your module i.e. define (    module_id   /*optional*/ ,   [ dependencies ]  /*optional*/ ,    definition   function   /*function for instantiating the module or object*/ ); And define ([ 'moduleA' ,  'moduleB' ],  function  ( moduleA ,  moduleB ) {    //define the module value by returning a value    return   function  () {}; }); The require () method looks like - ü    The require () method is used for handling dependency loading ü    The require () function doesn't have to return the implementation of a new module. require ([ 'j...