Mashboard too slow

qedgenx
User offline. Last seen 45 weeks 16 hours ago. Offline
Joined: 08/04/2009
Points: 50

Hi,

Our customer required 15 tabs in mashboard always, each of them are built by 3 or 4 mashlets which each of them are using 3 or 4 mashups loading catalogs from a database or querying excel services or making calculations. Works fine, issue is when trying to display in IE or Firefox for the first time, mashboard downloading - displaying all contents is tooooo slow. Sometimes returns errors due to functions not completly loaded, etc.

How can I refactor code to use caché, reuse javascripts declared in mashlet.json (firebug shows each script or css is always loaded even if was previously load by other mashlet) so network is very slow, display the whole mashboard takes around 10 mins to load everything. Desesperado user wants die due to this.

We're displaying charts and grids mainly. I added a main js in mashboard/index.jsp to include everything once. This works, however some of this mashlets will be displayed in sharepoint, standalone, so won't be available my little hack  <script type="text/javascript" src="/mashlets/allMashletsFoundation/all.js"></script>

Any ideas, or tip to load only one javascript library dependencies even if mashlet is displayed in sharepoint or mashboard?

thanks in advance

0
Your rating: None
jeremy.pitten
jeremy.pitten's picture
User offline. Last seen 2 weeks 6 days ago. Offline
Joined: 09/22/2008
Points: 275

10 minutes is a ridiculous amount of time to load mashboard. How long does it take for mashboard to load subsequent times, once the files are cached?

Your comment "Sometimes returns errors due to functions not completly loaded, etc.", is worrying, it suggests that the mashlet type definition in mashlet.json is not complete. For each javascript file to be loaded, defined in the array <mashlet type>.resources.js, each object entry should specify a property, named "property", with a value which is uniquely defined by that js file, which will only exist once the js file has been loaded. For a mashlet this will usually be the mashlet class name, eg. Presto.ServiceMashlet.

If a property is not specified for a js file then the loading mechanism assumes there is no need to wait before loading the next queued file, which can disrupt the file loading order, this is problem which can affect mashlets running on IE.

In your case, the problem with this mechanism for checking that a file has fully loaded is that the check isnt performed until after we have tried to load the file. Ideally, you need to be able to check that the mashlet implementation is already present before trying to load the mashlet resources. So with your mashboard/index.jsp patched to include all your mashlets i a single file, src="/mashlets/allMashletsFoundation/all.js", you need to override the script loading functionality to check to see if each mashlet is already available before proceeding to load.

The following block of code overrides the Ema.Container.loadScripts method, which you will find in /static/mashlets/js/mashlet-core-debug.js, you can include it in your /mashboard/index.jsp.

               var loadScripts = Ema.Container.prototype.loadScripts;
                Ema.Container.prototype.loadScripts = function(mashletType, jsFiles, callback) {
                    if(jsFiles){
                        for(var i=0; i < jsFiles.length; i++) {
                            if (jsFiles[i].property) {
                                var conditionCheck = this.createConditionCheck(jsFiles[i].property);
                                if(conditionCheck()){
                                    // property already exists so we dont need to load this file
                                    jsFiles.splice(i, 1);
                                }
                            }
                        }
                        if(jsFiles.length > 0){
                            // one or more files still need to be loaded..
                            loadScripts.call(this, mashletType, jsFiles, callback);                         
                        } else {
                            // all conditions have been met so assume successful completion
                            callback.onSuccess.apply(callback.scope);
                        }
                    }
                }

 

So try using this patch together with your concatenated js file, and make sure you define a property for each js file to be loaded.

Another option, rather than having all of your tabs and their content rendered at startup you could add some of then as toolbar buttons, so that they are only loaded on demand. See the mashboard toolbar menu Options->"Add Toolbar Button".