javascript/css unordered render ?

May 4, 2010 at 7:11 PM


Great idea and compressing fine ! But I've some rendering problems with more complex projects in which the order is important. For example, I could load theses files in this exact order :

1) jquery.x.js

2) jquery.prettyPhoto.js

3) products.js

4) product-utils.js

5) cart.js

6) cart-utils.js, ....


It seems that it doesn't consider the priorities, and may causes disasters like this :

1) jquery.prettyPhoto.js (jquery not defined)

2) product-utils.js (product not defined)

3) jquery (ok now we know what is jquery, but that's useless now)

4) ...


I tried CombineHeaderScripts="false", so the order of scripts in the header is correct in the source code, but still having problems. I suspect that other scripts outside of the header are still loaded in a different order than the original page. I don't think that it is the compression that "creates" errors in already working scripts. Is there a config to force the compression and combine to consider those priorities ? Or is there a solution to render correctly this kind of context with the compression without "jumping" over the problem ?


May 18, 2010 at 5:21 PM

Seems that nobody has an idea of what's going on. Personally I can't modify every single project to match with the built-in priorities of MbCompression. Thanks to anyone that have an explanation.

Oct 12, 2010 at 7:50 AM

Can you supply me a working example project with the error?

Mar 18, 2011 at 3:18 PM

I have the same problem. In our webproject we have lots of user controls. My colleagues and me sometimes load jquery plugins in those controls. The javascript files for those controls seem to load before the javascript files in the header. That is where we load the jquary lib, so we get errors. It would be nice if the javascripts in the header keep the same order or you can specify it. Anyway, the javascripts in the body of the page should load after the ones in the header.

I could send you an example if you'd like that. Just let me know.


May 20, 2011 at 10:04 AM

Hi SvenT,

It will helpful if you will send me an example so I can check it


Sep 23, 2011 at 4:46 AM

Hello, seems like this thread has been awaken again. Is it fixed ? Otherwise, I suggest to create a temp directory on the server-side that contains every header scripts at the root. The main problem is that you just can't combine every scripts of a specific subfolder without considering other files.

For example :

In the header, I need this exact order : "a/script1.js", "b/script2.js", "a/script3.js". The subfolder combining will result in "a/combine[script1,script3]", "b/combine[script2]" and there is no way to choose wisely which one to combine first. Both cases will result in errors.


Now with a temp root directory, suppose that you have the same exact order : "a/script1.js", "b/script2.js", "a/script3.js".

Let's call the directory omething like "_combineHeaderRoot" and copy every scripts into it once and for all. With this new temp structure, you can easily keep a trace of the arrival order of the scripts, then combine them this way : "_combineHeaderRoot/combine[script1,script2,script3]". It should now keep the original order while combining the header scripts.

I hope this helps.