Jerry.William.Ho
Jerry.William.Ho

Reputation: 37

how to deal with the dynamic loading of extjs 4 when releasing to server?

I often use the Ext.require() functionality of Extjs which lets the it dynamically load the specific content.

But the documentation specifies that when released to the production environment, the dynamic loading feature should never be used. So how can I deal with so many Ext.requires() in my code? The official doc said that the sencha cmd could solve this problem if you follow the scaffolding. But I didn't know about the sencha cmd when I wrote the code.

So, how should I update my code?

Upvotes: 0

Views: 315

Answers (1)

Federico Baron
Federico Baron

Reputation: 997

The simplest way to merge all your JS files into a production build (taking care of ExtJS requirements) is to use SenchaCMD.

If you didn't follow CMD practices during development it could be quite hard. Fortunately your JS source code will not be changed, you must only be sure to have defined "requires" attribute correctly instead of using Ext.requires (otherwise it would continue to use dynamic loading...).

It really depends on you project structure and you coding style, but steps are:

  • Download Sencha CMD (last version)
  • Create a fresh Sencha app with "sencha generate app"
  • Add your application start logic in the "launch" method of Application.js (consider adding also all your missing requirements in this class)
  • Add all your source files in the app folder and try to run "sencha app build" (better if you add a subset of your app, try to build it, eventually fix it, the add another part).
  • Now you should have 2 new builds: "production build" is a single file minified JS, "testing build" is single file non mified. There is also a "development mode" of sencha CMD that starts a Tomcat server and deploy you application as you are doing now.

Upvotes: 1

Related Questions