4

Resolved

Resources not being included in correct order (intermittent issue)

description

This seems to have started happening within the past month, and it's a little annoying during development.

Here's what happens: you make some changes, hit Ctrl+F5, and javascript doesn't work properly on your site. You look at the console in browser's dev tools, and see errors like "Uncaught ReferenceError: jQuery is not defined". In the view source, you notice that jquery.js is being included after scripts that have declared a dependency on jquery.js. For example, in one of my pages where I'm having this issue, I'm using these Script includes in my .cshtml:
Script.Require("jQuery");
Script.Require("jQueryUI_Button");
Script.Require("jQueryUI_Tabs");
Script.Require("jQueryUI_Slider");
Script.Require("jQueryUI_Dialog");
Script.Require("jQueryUI_Slider");
, and the jQueryUI_... resources have declared deps on jQuery. But they are included before jquery in the html.

Usually after one or more cycles of killing Cassini, cleaning the solution, rebuilding, and launching via Ctrl+F5 again, the problem goes away for a while. We mentioned this during this week's orchard weekly meeting and at least one or two other people mentioned they too were having this problem.

file attachments

comments

Piedone wrote Nov 12, 2012 at 12:33 PM

I just stumbled upon this as well. A Cassini restart solved it. In my particlar case MediaPicker and jQuery UI got included before jQuery itself. My template has a Script.Require("jQuery").AtFoot() with some inline js using (Script.Foot()) at the bottom.

paynecrl97 wrote Nov 21, 2012 at 11:30 AM

I have noticed this, and logged an issue with id 19263. I didn't realise it had already been logged when I raised my issue.

sebastienros wrote Dec 18, 2012 at 7:48 AM

Should be fixed in 1.x now, please check

** Closed by sebastienros 12/18/2012 12:48AM

paynecrl97 wrote Dec 20, 2012 at 1:12 PM

This happens for me in 1.6.

In fact, it's just happened again. See the attached screen shot. You can see that the Layout.cshtml file includes jQuery, bootstrap.min, jCarousellite then bootstrapcasino.js. However, files are rendered as bootstrap.min, jCarousellite then bootstrapcasino.js then jQuery- causing the javascript errors in the console.

Can this be re-opened please?

TheMonarch wrote Dec 20, 2012 at 2:06 PM

@paynecrl97, Which changeset did you test with?

paynecrl97 wrote Jan 7, 2013 at 3:11 PM

@TheMonarch, I get this with Orchard v1.6.0.0

pszmyd wrote Aug 20, 2013 at 8:35 PM

Reopened as found the real issue behind it (multi-threading issue when generating proper shape names for resources). Fix is on it's way.

pszmyd wrote Aug 20, 2013 at 9:02 PM

Fixed in changeset b95ce0cc7d7868a5f6b474fa68898c9ac3fda7b2

GregoryHill wrote Apr 8 at 6:54 PM

Has this fix been integrated into any releases? I'm currently using 1.7.2, and am suddenly encountering a very similar issue.

One of the more interesting manifestations is that if I have javascript embedded in the cshtml file, it executes fine. But if I include it as a separate file, it won't run at all.