Features of 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 therequirejs.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 required when Require is specified as config object before loading RequireJS.
ü  xhtml - It is used to create the script elements by using the document.createElementNS() method.
ü  scriptType - 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'
        }
    }
});

I hope you are enjoying with this post! Please share with you friends!! Thank you!!!
ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - https://code-sample.com and https://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions