Try Upgrade Adviser – Scan Your Ext JS Codebase for V8 App Upgrade

New! Try dark mode

Stop Bloating Your Bundle: Dynamic Package Loading in Ext JS

April 20, 2026 947 Views

Get a summary of this article:

Show

Stop Bloating Your Bundle: Dynamic Package Loading in Ext JS

Performance is not just a feature; it’s a requirement. For large-scale enterprise applications, the biggest enemy of a smooth User Experience (UX) is the Initial Load Time. If your app-all.js is several megabytes, you are making your users wait for code they might not even use in that session.

It’s time to stop ship-everything-at-once builds. Let’s look at how to use Dynamic Package Loading with Sencha Cmd to modularize your app and slash your bundle size.

The Strategy: Requires vs. Uses

By default, when you put a package in the requires array of your app.json, Sencha Cmd merges everything into the main bundle. To decouple them, we move secondary features to the uses array.

1. Configure app.json

First, ensure you have the package-loader in your requirements and move your heavy modules to the uses section.

JSON


    {
        "requires": [
            "package-loader"
        ],
        "uses": [
            "ReportsModule",
            "AdminDashboard"
        ]
    }

2. Implementation: Loading on Demand

Instead of the framework loading these packages at startup, you control the execution using Ext.Package.load(). This is particularly powerful when hooked into Routes.

JavaScript


    // Example: Loading a Reporting module only when the user navigates to the route
    routes: {
        'reports/:type': {
            before: 'ensurePackageLoaded',
            action: 'showReport'
        }
    },

    ensurePackageLoaded: function(type, action) {
        var pkg = 'ReportsModule';

        if (Ext.Package.isLoaded(pkg)) {
            action.resume();
        } else {
            Ext.getBody().mask('Loading Module...');
            
            Ext.Package.load(pkg).then(function() {
                Ext.getBody().unmask();
                action.resume();
            });
        }
    }

Tree Shaking & Build Optimization

Dynamic loading is half the battle. To ensure the packages themselves are lean, leverage Sencha Cmd’s compiler capabilities:

  • Dead Code Elimination: Sencha Cmd’s compiler automatically performs tree shaking by analyzing class requirements. Avoid using Ext.create(‘ClassName’) with strings; use xtype or proper requires blocks so the compiler can safely include only what’s used.
  • Build Switch: When building, use the –uses flag to tell Cmd to generate separate bundles for your dynamic packages.

Bash


    sencha app build production --uses

Why this matters for the Developer

  1. Faster Upgrades: By modularizing features into packages, you can update or refactor specific modules without risking the stability of the entire core application.
  2. Modular Maintenance: Teams can work on separate packages (e.g., Inventory vs. Billing) with clear boundaries.
  3. Lightweight Initial Footprint: Your core app.js only contains the essential “Shell” and common logic, making the first “Time to Interactive” (TTI) lightning fast.

Documentation References

Conclusion

Stop treating your enterprise app like a monolith. Use Dynamic Package Loading to deliver only what the user needs, exactly when they need it. Your bundle and your users will thank you.

Looking to Upgrade to 8.0?

The free-to-use Ext JS Upgrade Adviser tool helps identify code changes required to migrate to the latest Ext JS version. Give it a try!

Join the Sencha Discord Server

Are you looking for community engagement? Want to help, learn and share with many Ext JS experts? Join Sencha Discord Server now for free and be part of our community!

  • Sencha MVPs are there
  • Sencha developers are there
  • Expand awareness of Sencha products
  • Community Engagement and Contributions
  • And more…

Recommended Articles

Top 8 Best Practices for Enterprise Software Development in 2026

Enterprise software development in 2026 demands a different approach than consumer application development. Enterprise teams must prioritize scalability, performance, security, accessibility, and long-term maintenance from…

JavaScript Framework vs Library: Key Differences Explained for 2026

JavaScript frameworks and libraries serve different purposes in enterprise development. Frameworks such as Ext JS provide a complete application architecture with built-in components, routing, and…

UI Framework Trends in 2026: AI Integration, Accessibility, and Enterprise Performance

UI frameworks in 2026 are defined by three significant shifts: deeper integration of AI-related components into mainstream development, mandatory accessibility compliance, and stronger data grid…

How to Choose a UI Framework for Enterprise Applications: A 2026 Decision Guide

Selecting the right UI framework for enterprise applications requires evaluating component completeness, data handling performance, and long-term support. Enterprise teams prioritize frameworks that provide comprehensive…

The Complete Guide to Form Validation in JavaScript (Client & Server Side)

Form validation is one of the most important parts of building reliable web applications. Whether users are signing up, submitting payment details, updating account settings,…

Debugging JavaScript Applications: Tools and Techniques for Faster Troubleshooting

Debugging is an unavoidable part of JavaScript development. No matter how experienced a developer is, bugs still happen: unexpected UI behavior, failed API requests, timing…

View More