PDA

View Full Version : Dynamic loading



badboyii
13 Jun 2012, 5:35 PM
I am new to Ext, so I apologize in advance if I am asking a question that has been asked before.

I am working on an existing application that makes extensive use of Ext, with the goal of making it leaner and faster. Right now, the application is including ext-all.js and, while everything works fine, the file is more than 1Mb in size. I read the section about Dynamic Loading (2.2) in http://www.sencha.com/learn/getting-started-with-ext-js-4 (http://www.sencha.com/learn/getting-started-with-ext-js-4), and I was under the impression that I could include ext.js, and then Ext will automatically figure out dependencies and load them as necessary.

In fact, I followed the simple tutorial presented in the Getting Started guide, and everything works, with Ext.container.Viewport automatically loaded. However, I then tried to add a simple AJAX call, and that failed. In order to make it work, I had to manually include Ajax.js, data/connection.js (Ext.data.Connection is required by Ext.Ajax) and Ext.util.Observable (this mixin is quired by Ext.data.Connection). The application I am working on is rather extensive and solving all dependencies manually would be a nightmare. I tried the Sencha SDK tool, which I believe should be able to generate a JSB file, allowing me to build a library with only the components I need, but it doesn't seem to work properly.

Is there any way that I could have Ext automatically load all the necessary files? If not, why is it that the library can automatically load the correct file for Ext.container.Viewport, but won't work with Ext.Ajax?

mitchellsimoens
26 Jun 2012, 8:31 AM
Require the class in the class that needs it.