3

Resolved

Resources not being included in the correct order or at the correct location

description

I know this has been raised before, but those issues have been closed without resolution.

There is a bug with the way that Orchard includes external resources. I experience this with Orchard 1.6.

I have a page with the following declarations:
    Script.Include("RealmCanvas/libs/greensock/TweenMax.min.js").AtHead();
    Script.Include("RealmCanvas/libs/greensock/plugins/EaselPlugin.min.js").AtHead();
    Script.Include("RealmCanvas/libs/easeljs-0.5.0.min.js").AtHead();
    Script.Include("RealmCanvas/libs/tweenjs-0.3.0.min.js").AtHead();
    Script.Include("RealmCanvas/libs/movieclip-0.5.0.min.js").AtHead();
    Script.Include("RealmCanvas/libs/preloadjs-0.2.0.min.js").AtHead();
    Script.Include("RealmCanvas/libs/soundjs.js").AtHead();


    Script.Include("RealmCanvas/filters/Filter.js").AtHead();
    Script.Include("RealmCanvas/filters/BoxBlurFilter.js").AtHead();
    Script.Include("RealmCanvas/filters/ColorFilter.js").AtHead();

    Script.Include("RealmCanvas/Version.js").AtHead();
    Script.Include("RealmCanvas/Debug.js").AtHead();
    Script.Include("RealmCanvas/ScreenConsole.js").AtHead();
    Script.Include("RealmCanvas/IslandData.js").AtHead();
    Script.Include("RealmCanvas/Assets.js").AtHead();
    Script.Include("RealmCanvas/Rays.js").AtHead();
    Script.Include("RealmCanvas/LoadingIndicator.js").AtHead();
    Script.Include("RealmCanvas/IntroClouds.js").AtHead();
    Script.Include("RealmCanvas/FPSCounter.js").AtHead();
    Script.Include("RealmCanvas/Utils.js").AtHead();
    Script.Include("RealmCanvas/SimpleParticle.js").AtHead();
    Script.Include("RealmCanvas/SimpleParticleSystem.js").AtHead();

    Script.Include("RealmCanvas/Island.js").AtHead();
    Script.Include("RealmCanvas/ParallaxLayer.js").AtHead();
    Script.Include("RealmCanvas/ParallaxEngine.js").AtHead();


    Script.Include("RealmCanvas/Backdrop.js").AtHead();
    Script.Include("RealmCanvas/assets/Arrows.js").AtHead();
This gets resolved as:
<script src="/OrchardLocal/Modules/GRMS/Scripts/easeljs-0.5.0.min.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/Scripts/tweenjs-0.3.0.min.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/Scripts/movieclip-0.5.0.min.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/Scripts/soundjs.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/Scripts/LoadingIndicator.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="/OrchardLocal/Core/Shapes/Scripts/html5.js" type="text/javascript"></script>
<![endif]-->
<meta content="Orchard" name="generator" />
<link href="/OrchardLocal/modules/orchard.themes/Content/orchard.ico" rel="shortcut icon" type="image/x-icon" />
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/libs/greensock/TweenMax.min.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/libs/greensock/plugins/EaselPlugin.min.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/libs/preloadjs-0.2.0.min.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/filters/Filter.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/filters/BoxBlurFilter.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/filters/ColorFilter.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Version.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Debug.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/ScreenConsole.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/IslandData.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Assets.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Rays.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/IntroClouds.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/FPSCounter.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Utils.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/SimpleParticle.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/SimpleParticleSystem.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Island.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/ParallaxLayer.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/ParallaxEngine.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/Backdrop.js" type="text/javascript"></script>
<script src="/OrchardLocal/Modules/GRMS/scripts/RealmCanvas/assets/Arrows.js" type="text/javascript"></script>

Note that the scripts are rendered in two distinct blocks- separated by a conditional include, a meta tag and a link tag. This causes the scripts to be rendered in the incorrect order- i.e. the scripts that appear in the first block appear on the page before they should. This causes JS errors on the page if objects in one script depend on another that has incorrectly been loaded after the dependent script.

Also note that the scripts in the first block reference different file paths to those that have been specified- i.e. the scripts that are referenced are not within the RealmCanvas folder as they should be.

The five scripts in the first block reference scripts in the root of the scripts folder with the same name. Removing the script in the root of the script folder will cause Orchard to render the script tag in the correct location in the document, and with the correct path to the file.

comments

Piedone wrote Feb 14, 2013 at 6:04 PM

Isn't this issue the same? Have you checked with the latest source?

paynecrl97 wrote Feb 15, 2013 at 9:59 AM

@Piedone Yes, that is a similar issue. It got closed as "fixed in 1.x", but it is still occurring in 1.6.

Additionally, this issue adds the fact that the incorrect script is included when more than one script with the same name exist in different locations in the same Scripts folder.

AimOrchard wrote Feb 15, 2013 at 11:51 AM

He means its fixed on the 1.x trunk / branch. It'll be included in the next release.

If you wish to have the fix before then you'll have to apply the fix yourself (as did we)