Sencha Documentation

Ext.Loader is the heart of the new dynamic dependency loading capability in Ext JS 4+. It is most commonly used via the Ext.require shorthand
Ext.require([
    'widget.window',
    'widget.button',
    'layout.fit'
]);

Ext.onReady(function() {
    var window = Ext.widget('window', {
        width: 500,
        height: 300,
        layout: 'fit',
        items: {
            xtype: 'button',
            text: 'Hello World',
            handler: function() { alert(this.text) }
        }
    });

    window.show();
});

Config Options

 
enabled : Boolean
 
paths : Object

Properties

 
history : Array
An array of class names to keep track of the dependency loading order. This is not guaranteed to be the same everytim...
An array of class names to keep track of the dependency loading order. This is not guaranteed to be the same everytime due to the asynchronous nature of the Loader.
 
if : Object
Automatically detect deadlocks before-hand, will throw an error with detailed path for ease of debugging. Examples of...
Automatically detect deadlocks before-hand, will throw an error with detailed path for ease of debugging. Examples of deadlock cases: - A extends B, then B extends A - A requires B, B requires C, then C requires A The detectDeadlock function will recursively transverse till the leaf, hence it can detect deadlocks no matter how deep the path is.

Methods

 
exclude : Void
Explicitly exclude
Explicitly exclude
 
getConfig( String name ) : Object/Mixed
Get the config value corresponding to the specified name. If no name is given, will return the config object
Get the config value corresponding to the specified name. If no name is given, will return the config object

Parameters

  • name : String
    The config property name

Returns

  • Object/Mixed   undefined
 
getPath( String className ) : String
Translates a className to a path to load the file from by prefixing the proper prefix and converting the .'s to /'s. ...
Translates a className to a path to load the file from by prefixing the proper prefix and converting the .'s to /'s. For example: ("Ext.layout.Layout" => "./src/Ext/layout/Layout.js")

Parameters

  • className : String

Returns

  • String   path
 
onReady( Function fn, Object scope, Boolean withDomReady ) : Void
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

Parameters

  • fn : Function
    The function callback to be executed
  • scope : Object
    The execution scope (this) of the callback function
  • withDomReady : Boolean
    Whether or not to wait for document dom ready as well

Returns

  • Void
 
setConfig( Object config ) : Ext.Loader
Set the configuration for the loader. This should be called right after ext-core.js (or ext-core-debug.js) is include...
Set the configuration for the loader. This should be called right after ext-core.js (or ext-core-debug.js) is included in the page, i.e:
<script type="text/javascript" src="ext-core-debug.js"></script>
<script type="text/javascript">
Ext.Loader.setConfig({
enabled: true,
paths: {
'My': 'my_own_path'
}
});
</script>
<script type="text/javascript">
Ext.require(...);
Ext.onReady(function() {
// application code here
});
</script>
Refer to Ext.Loader.config for the list of possible properties

Parameters

Returns

  • Ext.Loader   this
 
setPath( String/Object name, String path ) : Void
Sets the path of a namespace. For Example: Ext.Loader.setPath('Ext', '.'); Indicates that any classes with the top le...
Sets the path of a namespace. For Example: Ext.Loader.setPath('Ext', '.'); Indicates that any classes with the top level object "Ext" will be found at the root basePath.

Parameters

Returns

  • Void