Ext.data.JsonP.Ext_Loader({"alternateClassNames":[],"aliases":{},"enum":null,"parentMixins":[],"tagname":"class","subclasses":[],"extends":null,"uses":[],"html":"

Files

Ext.Loader is the heart of the new dynamic dependency loading capability in Ext JS 4+. It is most commonly used\nvia the Ext.require shorthand. Ext.Loader supports both asynchronous and synchronous loading\napproaches, and leverage their advantages for the best development flow. We'll discuss about the pros and cons of each approach:

\n\n

Asynchronous Loading

\n\n\n\n\n

Method 1: Explicitly include what you need:

\n\n
// Syntax\nExt.require({String/Array} expressions);\n\n// Example: Single alias\nExt.require('widget.window');\n\n// Example: Single class name\nExt.require('Ext.window.Window');\n\n// Example: Multiple aliases / class names mix\nExt.require(['widget.window', 'layout.border', 'Ext.data.Connection']);\n\n// Wildcards\nExt.require(['widget.*', 'layout.*', 'Ext.data.*']);\n
\n\n

Method 2: Explicitly exclude what you don't need:

\n\n
// Syntax: Note that it must be in this chaining format.\nExt.exclude({String/Array} expressions)\n   .require({String/Array} expressions);\n\n// Include everything except Ext.data.*\nExt.exclude('Ext.data.*').require('*');\n\n// Include all widgets except widget.checkbox*,\n// which will match widget.checkbox, widget.checkboxfield, widget.checkboxgroup, etc.\nExt.exclude('widget.checkbox*').require('widget.*');\n
\n\n

Synchronous Loading on Demand

\n\n\n\n\n

There's one simple rule to follow: Instantiate everything with Ext.create instead of the new keyword

\n\n
Ext.create('widget.window', { ... }); // Instead of new Ext.window.Window({...});\n\nExt.create('Ext.window.Window', {}); // Same as above, using full class name instead of alias\n\nExt.widget('window', {}); // Same as above, all you need is the traditional `xtype`\n
\n\n

Behind the scene, Ext.ClassManager will automatically check whether the given class name / alias has already\n existed on the page. If it's not, Ext.Loader will immediately switch itself to synchronous mode and automatic load the given\n class and all its dependencies.

\n\n

Hybrid Loading - The Best of Both Worlds

\n\n

It has all the advantages combined from asynchronous and synchronous loading. The development flow is simple:

\n\n

Step 1: Start writing your application using synchronous approach.

\n\n

Ext.Loader will automatically fetch all dependencies on demand as they're needed during run-time. For example:

\n\n
Ext.onReady(function(){\n    var window = Ext.widget('window', {\n        width: 500,\n        height: 300,\n        layout: {\n            type: 'border',\n            padding: 5\n        },\n        title: 'Hello Dialog',\n        items: [{\n            title: 'Navigation',\n            collapsible: true,\n            region: 'west',\n            width: 200,\n            html: 'Hello',\n            split: true\n        }, {\n            title: 'TabPanel',\n            region: 'center'\n        }]\n    });\n\n    window.show();\n})\n
\n\n

Step 2: Along the way, when you need better debugging ability, watch the console for warnings like these:

\n\n
[Ext.Loader] Synchronously loading 'Ext.window.Window'; consider adding Ext.require('Ext.window.Window') before your application's code\nClassManager.js:432\n[Ext.Loader] Synchronously loading 'Ext.layout.container.Border'; consider adding Ext.require('Ext.layout.container.Border') before your application's code\n
\n\n

Simply copy and paste the suggested code above Ext.onReady, i.e:

\n\n
Ext.require('Ext.window.Window');\nExt.require('Ext.layout.container.Border');\n\nExt.onReady(...);\n
\n\n

Everything should now load via asynchronous mode.

\n\n

Deployment

\n\n

It's important to note that dynamic loading should only be used during development on your local machines.\nDuring production, all dependencies should be combined into one single JavaScript file. Ext.Loader makes\nthe whole process of transitioning from / to between development / maintenance and production as easy as\npossible. Internally Ext.Loader.history maintains the list of all dependencies your application\nneeds in the exact loading sequence. It's as simple as concatenating all files in this array into one,\nthen include it on top of your application.

\n\n

This process will be automated with Sencha Command, to be released and documented towards Ext JS 4 Final.

\n
Defined By

Config options

Appends current timestamp to script files to prevent caching. ...

Appends current timestamp to script files to prevent caching.

\n

Defaults to: true

The get parameter name for the cache buster's timestamp. ...

The get parameter name for the cache buster's timestamp.

\n

Defaults to: '_dc'

Whether or not to enable the dynamic dependency loading feature. ...

Whether or not to enable the dynamic dependency loading feature.

\n

Defaults to: false

True to prepare an asynchronous script tag for garbage collection (effective only\nif preserveScripts is false) ...

True to prepare an asynchronous script tag for garbage collection (effective only\nif preserveScripts is false)

\n

Defaults to: false

The mapping from namespaces to file paths\n\n{\n 'Ext': '.', // This is set by default, Ext.layout.container.Containe...

The mapping from namespaces to file paths

\n\n
{\n    'Ext': '.', // This is set by default, Ext.layout.container.Container will be\n                // loaded from ./layout/Container.js\n\n    'My': './src/my_own_folder' // My.layout.Container will be loaded from\n                                // ./src/my_own_folder/layout/Container.js\n}\n
\n\n

Note that all relative paths are relative to the current HTML document.\nIf not being specified, for example, Other.awesome.Class\nwill simply be loaded from ./Other/awesome/Class.js

\n

Defaults to: {'Ext': '.'}

False to remove and optionally garbage-collect asynchronously loaded scripts,\nTrue to retain script element for brows...

False to remove and optionally garbage-collect asynchronously loaded scripts,\nTrue to retain script element for browser debugger compatibility and improved load performance.

\n

Defaults to: true

millisecond delay between asynchronous script injection (prevents stack overflow on some user agents)\n'false' disable...

millisecond delay between asynchronous script injection (prevents stack overflow on some user agents)\n'false' disables delay but potentially increases stack load.

\n

Defaults to: false

Optional charset to specify encoding of dynamic script content.

\n

Optional charset to specify encoding of dynamic script content.

\n
Defined By

Properties

Ext.Loader
view source
config : Objectprivate

Configuration

\n

Configuration

\n
Ext.Loader
view source
documentHead : Objectprivate
\n
\n
...
\n

Defaults to: false

An array of class names to keep track of the dependency loading order. ...

An array of class names to keep track of the dependency loading order.\nThis is not guaranteed to be the same everytime due to the asynchronous\nnature of the Loader.

\n

Maintain the list of files that have already been handled so that they never get double-loaded

\n

Maintain the list of files that have already been handled so that they never get double-loaded

\n
Ext.Loader
view source
isFileLoaded : Objectprivate
\n
\n
Ext.Loader
view source
isInHistory : Objectprivate
\n
\n
Ext.Loader
view source
: Booleanprivate
Flag indicating whether there are still files being loaded ...

Flag indicating whether there are still files being loaded

\n

Defaults to: false

...
\n

Defaults to: 0

...
\n

Defaults to: 0

Contains classes referenced in uses properties.

\n

Contains classes referenced in uses properties.

\n
Ext.Loader
view source
: Objectprivate
Maintain the queue for all dependencies. ...

Maintain the queue for all dependencies. Each item in the array is an object of the format:

\n\n
{\n     requires: [...], // The required classes for this queue item\n     callback: function() { ... } // The function to execute when all classes specified in requires exist\n}\n
\n

Maintain the list of listeners to execute when all required scripts are fully loaded

\n

Maintain the list of listeners to execute when all required scripts are fully loaded

\n
Ext.Loader
view source
requiresMap : Objectprivate

Map of fully qualified class names to an array of dependent classes.

\n

Map of fully qualified class names to an array of dependent classes.

\n
The number of scripts loading via loadScript. ...

The number of scripts loading via loadScript.

\n

Defaults to: 0

...
\n

Defaults to: false

Defined By

Methods

Ext.Loader
view source
( paths ) : Ext.Loaderchainable
Sets a batch of path entries ...

Sets a batch of path entries

\n

Parameters

  • paths : Object

    a set of className: path mappings

    \n

Returns

Ext.Loader
view source
( classes )private
Ensure that any classes referenced in the uses property are loaded. ...

Ensure that any classes referenced in the uses property are loaded.

\n

Parameters

Ext.Loader
view source
( script, remove, collect )private
...
\n

Parameters

Ext.Loader
view source
( disable, [path] )private
Turns on or off the \"cache buster\" applied to dynamically loaded scripts. ...

Turns on or off the \"cache buster\" applied to dynamically loaded scripts. Normally\ndynamically loaded scripts have an extra query parameter appended to avoid stale\ncached scripts. This method can be used to disable this mechanism, and is primarily\nuseful for testing. This is done using a cookie.

\n

Parameters

  • disable : Boolean

    True to disable the cache buster.

    \n
  • path : String (optional)

    An optional path to scope the cookie.

    \n

    Defaults to: "/"

Ext.Loader
view source
( excludes ) : Object
Explicitly exclude files from being loaded. ...

Explicitly exclude files from being loaded. Useful when used in conjunction with a broad include expression.\nCan be chained with more require and exclude methods, eg:

\n\n
Ext.exclude('Ext.data.*').require('*');\n\nExt.exclude('widget.button*').require('widget.*');\n
\n\n

Ext.exclude is alias for exclude.

\n

Parameters

Returns

  • Object

    object contains require method for chaining

    \n
Ext.Loader
view source
( name ) : Object
Get the config value corresponding to the specified name. ...

Get the config value corresponding to the specified name. If no name is given, will return the config object

\n

Parameters

  • name : String

    The config property name

    \n

Returns

Ext.Loader
view source
( className ) : String
Translates a className to a file path by adding the\nthe proper prefix and converting the .'s to /'s. ...

Translates a className to a file path by adding the\nthe proper prefix and converting the .'s to /'s. For example:

\n\n
Ext.Loader.setPath('My', '/path/to/My');\n\nalert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/path/to/My/awesome/Class.js'\n
\n\n

Note that the deeper namespace levels, if explicitly set, are always resolved first. For example:

\n\n
Ext.Loader.setPath({\n    'My': '/path/to/lib',\n    'My.awesome': '/other/path/for/awesome/stuff',\n    'My.awesome.more': '/more/awesome/path'\n});\n\nalert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/other/path/for/awesome/stuff/Class.js'\n\nalert(Ext.Loader.getPath('My.awesome.more.Class')); // alerts '/more/awesome/path/Class.js'\n\nalert(Ext.Loader.getPath('My.cool.Class')); // alerts '/path/to/lib/cool/Class.js'\n\nalert(Ext.Loader.getPath('Unknown.strange.Stuff')); // alerts 'Unknown/strange/Stuff.js'\n
\n

Parameters

Returns

Ext.Loader
view source
( className )private
...
\n

Parameters

Ext.Loader
view source
( className )private
...
\n

Parameters

Ext.Loader
view source
( url, onLoad, onError, scope, charset )private
Inject a script element to document's head, call onLoad and onError accordingly ...

Inject a script element to document's head, call onLoad and onError accordingly

\n

Parameters

Ext.Loader
view source
( className )private
...
\n

Parameters

Ext.Loader
view source
( options )
Loads the specified script URL and calls the supplied callbacks. ...

Loads the specified script URL and calls the supplied callbacks. If this method\nis called before Ext.isReady, the script's load will delay the transition\nto ready. This can be used to load arbitrary scripts that may contain further\nExt.require calls.

\n

Parameters

  • options : Object/String

    The options object or simply the URL to load.

    \n
    • url : String

      The URL from which to load the script.

      \n
    • onLoad : Function (optional)

      The callback to call on successful load.

      \n
    • onError : Function (optional)

      The callback to call on failure to load.

      \n
    • scope : Object (optional)

      The scope (this) for the supplied callbacks.

      \n
Ext.Loader
view source
( url, onLoad, onError, scope, synchronous )private
Load a script file, supports both asynchronous and synchronous approaches ...

Load a script file, supports both asynchronous and synchronous approaches

\n

Parameters

Ext.Loader
view source
( className, filePath, errorMessage, isSynchronous )private
...
\n

Parameters

Ext.Loader
view source
( className, filePath )private
...
\n

Parameters

Ext.Loader
view source
( fn, scope, withDomReady )
Add a new listener to be executed when all required scripts are fully loaded ...

Add a new listener to be executed when all required scripts are fully loaded

\n

Parameters

  • fn : Function

    The function callback to be executed

    \n
  • scope : Object

    The execution scope (this) of the callback function

    \n
  • withDomReady : Boolean

    Whether or not to wait for document dom ready as well

    \n
Ext.Loader
view source
( )private
Refresh all items in the queue. ...

Refresh all items in the queue. If all dependencies for an item exist during looping,\nit will execute the callback and call refreshQueue again. Triggers onReady when the queue is\nempty

\n
Ext.Loader
view source
( url )private
...
\n

Parameters

Ext.Loader
view source
( expressions, [fn], [scope], [excludes] )
Loads all classes by the given names and all their direct dependencies; optionally executes\nthe given callback functi...

Loads all classes by the given names and all their direct dependencies; optionally executes\nthe given callback function when finishes, within the optional scope.

\n\n

Ext.require is alias for require.

\n

Parameters

  • expressions : String/Array

    Can either be a string or an array of string

    \n
  • fn : Function (optional)

    The callback function

    \n
  • scope : Object (optional)

    The execution scope (this) of the callback function

    \n
  • excludes : String/Array (optional)

    Classes to be excluded, useful when being used with expressions

    \n
Ext.Loader
view source
( config ) : Ext.Loaderchainable
Set the configuration for the loader. ...

Set the configuration for the loader. This should be called right after ext-(debug).js\nis included in the page, and before Ext.onReady. i.e:

\n\n
<script type=\"text/javascript\" src=\"ext-core-debug.js\"></script>\n<script type=\"text/javascript\">\n    Ext.Loader.setConfig({\n      enabled: true,\n      paths: {\n          'My': 'my_own_path'\n      }\n    });\n</script>\n<script type=\"text/javascript\">\n    Ext.require(...);\n\n    Ext.onReady(function() {\n      // application code here\n    });\n</script>\n
\n\n

Refer to config options of Ext.Loader for the list of possible properties

\n

Parameters

  • config : Object

    The config object to override the default values

    \n

Returns

Ext.Loader
view source
( name, [path] ) : Ext.Loaderchainable
Sets the path of a namespace. ...

Sets the path of a namespace.\nFor Example:

\n\n
Ext.Loader.setPath('Ext', '.');\n
\n

Parameters

Returns

Ext.Loader
view source
( expressions, [fn], [scope], [excludes] )
Synchronously loads all classes by the given names and all their direct dependencies; optionally\nexecutes the given c...

Synchronously loads all classes by the given names and all their direct dependencies; optionally\nexecutes the given callback function when finishes, within the optional scope.

\n\n

Ext.syncRequire is alias for syncRequire.

\n

Parameters

  • expressions : String/Array

    Can either be a string or an array of string

    \n
  • fn : Function (optional)

    The callback function

    \n
  • scope : Object (optional)

    The execution scope (this) of the callback function

    \n
  • excludes : String/Array (optional)

    Classes to be excluded, useful when being used with expressions

    \n
Ext.Loader
view source
( )private
...
\n
","superclasses":[],"meta":{"author":["Jacky Nguyen "],"docauthor":["Jacky Nguyen "]},"requires":[],"html_meta":{"author":null,"docauthor":null},"statics":{"property":[],"cfg":[],"css_var":[],"method":[],"event":[],"css_mixin":[]},"files":[{"href":"Loader.html#Ext-Loader","filename":"Loader.js"}],"linenr":5,"members":{"property":[{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"classNameToFilePathMap","id":"property-classNameToFilePathMap"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"config","id":"property-config"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"documentHead","id":"property-documentHead"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"hasFileLoadError","id":"property-hasFileLoadError"},{"tagname":"property","owner":"Ext.Loader","meta":{},"name":"history","id":"property-history"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"isClassFileLoaded","id":"property-isClassFileLoaded"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"isFileLoaded","id":"property-isFileLoaded"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"isInHistory","id":"property-isInHistory"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"isLoading","id":"property-isLoading"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"numLoadedFiles","id":"property-numLoadedFiles"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"numPendingFiles","id":"property-numPendingFiles"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"optionalRequires","id":"property-optionalRequires"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"queue","id":"property-queue"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"readyListeners","id":"property-readyListeners"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"requiresMap","id":"property-requiresMap"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"scriptsLoading","id":"property-scriptsLoading"},{"tagname":"property","owner":"Ext.Loader","meta":{"private":true},"name":"syncModeEnabled","id":"property-syncModeEnabled"}],"cfg":[{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"disableCaching","id":"cfg-disableCaching"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"disableCachingParam","id":"cfg-disableCachingParam"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"enabled","id":"cfg-enabled"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"garbageCollect","id":"cfg-garbageCollect"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"paths","id":"cfg-paths"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"preserveScripts","id":"cfg-preserveScripts"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"scriptChainDelay","id":"cfg-scriptChainDelay"},{"tagname":"cfg","owner":"Ext.Loader","meta":{},"name":"scriptCharset","id":"cfg-scriptCharset"}],"css_var":[],"method":[{"tagname":"method","owner":"Ext.Loader","meta":{"chainable":true},"name":"addClassPathMappings","id":"method-addClassPathMappings"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"addUsedClasses","id":"method-addUsedClasses"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"cleanupScriptElement","id":"method-cleanupScriptElement"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"disableCacheBuster","id":"method-disableCacheBuster"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"exclude","id":"method-exclude"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"getConfig","id":"method-getConfig"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"getPath","id":"method-getPath"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"getPrefix","id":"method-getPrefix"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"historyPush","id":"method-historyPush"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"injectScriptElement","id":"method-injectScriptElement"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"isAClassNameWithAKnownPrefix","id":"method-isAClassNameWithAKnownPrefix"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"loadScript","id":"method-loadScript"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"loadScriptFile","id":"method-loadScriptFile"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"onFileLoadError","id":"method-onFileLoadError"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"onFileLoaded","id":"method-onFileLoaded"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"onReady","id":"method-onReady"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"refreshQueue","id":"method-refreshQueue"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"removeScriptElement","id":"method-removeScriptElement"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"require","id":"method-require"},{"tagname":"method","owner":"Ext.Loader","meta":{"chainable":true},"name":"setConfig","id":"method-setConfig"},{"tagname":"method","owner":"Ext.Loader","meta":{"chainable":true},"name":"setPath","id":"method-setPath"},{"tagname":"method","owner":"Ext.Loader","meta":{},"name":"syncRequire","id":"method-syncRequire"},{"tagname":"method","owner":"Ext.Loader","meta":{"private":true},"name":"triggerReady","id":"method-triggerReady"}],"event":[],"css_mixin":[]},"inheritable":null,"private":null,"component":false,"name":"Ext.Loader","singleton":true,"override":null,"inheritdoc":null,"id":"class-Ext.Loader","mixins":[],"mixedInto":[]});