Results 1 to 3 of 3

Thread: Ext loads too much code

  1. #1
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,932
    Vote Rating
    548
      0  

    Default Ext loads too much code

    See the code fragment... the panel Header loads the Ext.draw.Component.

    The draw.Component requires pretty much the entire draw package. It loads both engines: VML and SVG, and it doesn't event check if the engine is supported. This is a ton of code, see this open ticket.

    I suggest adding conditional resource loading or even creating two header types: Vertical and Horizontal.

    Code:
    Ext.define('Ext.panel.Header', {
        extend: 'Ext.container.Container',
        uses: ['Ext.panel.Tool', 'Ext.draw.Component', 'Ext.util.CSS', 'Ext.layout.component.Body', 'Ext.Img'],

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    The issue is that the uses and requires need to be there before the class is created so you can't add to the uses array in the constructor.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,932
    Vote Rating
    548
      0  

    Default

    Quote Originally Posted by mitchellsimoens View Post
    The issue is that the uses and requires need to be there before the class is created so you can't add to the uses array in the constructor.
    I'd consider adding a conditional resource loader... perhaps along the line of yepnope.

    ... but even code like this would be more efficient:

    Code:
    Ext.define('Ext.draw.Surface', {
        ...
        requires: ['Ext.draw.CompositeSprite'],
    
        // uses: ['Ext.draw.engine.Svg', 'Ext.draw.engine.Vml', 'Ext.draw.engine.SvgExporter', 
    'Ext.draw.engine.ImageExporter'],
    
        uses: Ext.supports.Svg ? ['Ext.draw.engine.Svg', 'Ext.draw.engine.SvgExporter', 'Ext.draw.engine.ImageExporter'] : ['Ext.draw.engine.Vml'],
    Most of the time the headers are horizontal, so the drawing package is not needed.
    Last edited by LesJ; 6 Feb 2012 at 8:05 AM. Reason: Correct Ext.supports

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •