Ext JS 4 is by far the biggest overhaul we’ve ever made to Ext JS, and constitutes the most advanced JavaScript framework ever created. Almost every area of the framework has been upgraded, from the generated HTML to the class system. We’ve unified APIs, added incredible new capabilities, and improved the performance of the entire framework.
With Ext JS 4 we’ve been driven by three key goals: speed, robustness and ease of use. We wanted the framework to be as fast and as robust as possible on every browser, and to be easy to learn and use. To achieve this we took the whole framework back to the drawing board, and what we’ve come back with is the fastest, most bullet-proof version of Ext JS we’ve ever created. Best of all, we’ve managed to do it while staying true to the core experience of writing apps “the Ext JS way.”
Ext JS 4 supports almost any known web browsers, from Internet Explorer 6 to Chrome 11. During development, we recommend that you choose one of the following as the primary browsers for the best debugging experience:
Please refer to the dedicated Debugging Handbook guide on the recommended tools for each and every browser, as well as how to make use of them to aid development.
Even though a local web server is not a requirement to use Ext JS 4, it is still highly recommended that you develop with one, since XHR over local file:// protocol has cross origin restriction on most browsers.
Download Ext JS 4 SDK if you haven't done so. Unzip the package within your web root directory tree. This guide assumes that http://localhost/ext-4.0
points to the top level directory of the downloaded SDK.
Open http://localhost/ext-4.0/index.html
on your web browser. If a welcome page appears, you are all set.
Although not being mandatory, all suggestions listed below should be considered as best-practice guidelines to keep your application well organized, extensible and maintainable.
- appname
- app
- namespace
- Class1.js
- Class2.js
- ...
- resources
- css
- images
- ...
- app.js
- index.html
in which:
appname
is a directory containing all your application's source filesapp
contains all your classes, the naming style of which should follow the convention listed in the Class System guideresources
contains additional CSS and image files which are responsible for the look and feel of the application, as well as other static resources (XML, JSON, etc.)index.html
is the entry-point HTML documentapp.js
contains your own application's logicsAn Ext JS application is self-contained in a single HTML document, the content of which has this format:
<html>
<head>
<title>Application Name</title>
<link rel="stylesheet" type="text/css" href="path/to/sdk/resources/css/ext-all.css">
<script type="text/javascript" src="path/to/sdk/ext-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>
whereby:
path/to/sdk
points to Ext JS 4 SDK directory in section 1.4path/to/sdk/resources/css/ext-all.css
contains all styling information needed for the whole frameworkpath/to/sdk/ext(-debug).js
contains Ext JS 4 Core library (or path/to/sdk/ext-all(-debug).js
, as explained below)From this point you need to choose between 2 different library inclusion methods. Each has its own pros and cons listed below:
Include path/to/sdk/ext-all.js
(path/to/sdk/ext-all-debug.js
during development), which contains the whole framework.
Cons:
Debugging is difficult due to the fact that all source code is confined into one big file.
Include path/to/sdk/ext.js
(path/to/sdk/ext-debug.js
during development) which contains just the minimum core library, and make use of Ext.Loader for automatic dependencies resolution.
In summary, it is recommended that you should only use ext-all(-debug).js
if you need to shorten the initial learning curve. Otherwise, ext(-debug).js
is preferred in most cases for actual application development.
Last but not least, app.js
is the entry-point of your own application's logic. For a basic application, the typical format of which may look like this:
// Register namespaces and their corresponding paths to Ext.Loader
Ext.Loader.setPath({
'AppName': 'app',
... // Other namespaces
});
// Specify a list of classes your application your application needs
Ext.require([
...
]);
// Application's initialization
Ext.onReady(function() {
...
});
Ext JS 4 shipped with a robust MVC architecture which maximize extensibility and maintainability for medium to large scale applications. Please refer to the MVC Application Architecture guide for detailed instructions.
The newly introduced Sencha SDK Tools (download here makes deployment of any Ext JS 4 application easier than ever. The tools allows you to generate a manifest of all dependencies in the form of a JSB3 (JSBuilder file format) file, and create a minimal custom build of just what your application needs within minutes.
Once you've installed the SDK Tools, open a terminal window and navigate into your application's directory.
cd path/to/application
From here you only need to run a couple of simple commands. The first one generates a JSB3 file:
sencha create jsb -a index.html -p app.jsb3
This scans your index.html
file for all framework and application files that are actually used by the app, and then creates a JSB file called app.jsb3
. Generating the JSB3 first gives us a chance to modify the generated app.jsb3
before building - this can be helpful if you have custom resources to copy, but in most cases we can immediately proceed to build the application with the second command:
sencha build -p app.jsb3 -d .
This takes the JSB3 file and creates an app-all.js
, which is a minimized build of your application plus all of the Ext JS classes required to run it. It also creates an all-classes.js
file, which has the same classes as app-all.js
, but is not minified so is very useful for debugging problems with your built application. In short, app-all.js
is the minified and production-ready version of all-classes.js + app.js
.
Most applications will need a separate index.html
for the deployed version of the app, for example to add Analytics includes or other production-only logic into that file. Typically you would end up with a production index.html
file that looks like this:
<html>
<head>
<title>Application Name</title>
<link rel="stylesheet" type="text/css" href="path/to/sdk/resources/css/ext-all.css">
<script type="text/javascript" src="path/to/sdk/ext.js"></script>
<script type="text/javascript" src="app-all.js"></script>
</head>
<body></body>
</html>
Notice that path/to/sdk/ext-debug.js
has been replaced with path/to/sdk/ext.js
, and app.js
has been replaced with app-all.js
in this production version, comparing with the development one described in section 2.1
For applications built on top of a dynamic server-side language like PHP, Ruby, ASP, etc., you can simply replace index.html
in the first command to the actual URL of your application. This URL should be the same with what is viewable on the browsers during development. For example:
sencha create jsb -a http://localhost/path/to/application/index.php -p app.jsb3
Please check back soon