Jahia DX > Order of included...

0 (0 Good)
0 (0 Bad)

Order of included javascript?

by  rvt »  2011/06/07 18:05

Hello!

 

I am trying to understand how I can put some javascript elements always on top, or may be behind a other javascript include. For on, I want the jquery framework always ontop, and my own JS files below that.

For example, I have seen during the first hit of a page the following inclusion:

<script id="staticAssetJavascript0" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.js"></script>

<script id="staticAssetJavascript1" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.min.js"></script>

<script id="staticAssetJavascript2" type="text/javascript" src="/jahia/modules/assets/javascript/jquery-ui.min.js"></script>

<script id="staticAssetJavascript3" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.easySlider1.7.js"></script>

<script id="staticAssetJavascript4" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.easySlider1.7.load.js"></script>

<script id="staticAssetJavascript5" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.autocomplete.js"></script>

<script id="staticAssetJavascript6" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.bgiframe.min.js"></script>

<script id="staticAssetJavascript7" type="text/javascript" src="/jahia/modules/assets/javascript/thickbox-compressed.js"></script>

And when I just reload the page I get this inclusion order:

<script id="staticAssetJavascript0" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.easySlider1.7.js"></script>

<script id="staticAssetJavascript1" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.easySlider1.7.load.js"></script>

<script id="staticAssetJavascript2" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.autocomplete.js"></script>

<script id="staticAssetJavascript3" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.bgiframe.min.js"></script>

<script id="staticAssetJavascript4" type="text/javascript" src="/jahia/modules/assets/javascript/thickbox-compressed.js"></script>

<script id="staticAssetJavascript5" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.js"></script>

<script id="staticAssetJavascript6" type="text/javascript" src="/jahia/modules/assets/javascript/jquery.min.js"></script>

<script id="staticAssetJavascript7" type="text/javascript" src="/jahia/modules/assets/javascript/jquery-ui.min.js"></script>

<script id="staticAssetJavascript8" type="text/javascript" src="/jahia/modules/templates-librecad-aic/javascript/topmenu.js"></script>

As you can see in the below, on the second page hit the jquery.js and jquery.min.js scripts are all the way at the bottom. I am guessing this has something to do how Jahia caches pages and pages blocks?

Even when I add this in my templates, the jquery frameworks are at the bottom.

<template:addResources type="javascript" resources="jquery.min.js,topmenu.js" insert="true"/>

The only way to fix it, is remove jquery from my templates and only add it to my slider templates and use insert="true" on my slider to make it work reliable and predictable.

What is the best method to add some javascript frameworks always on top?

Ries

  • Order of included javascript?
    2011/06/30 15:33

    rvt <p> Hello!</p> <p class="p2"> &nbsp;</p> <p class="p1"> I am trying to understand how I can put some javascript elements always on top, or may be behind a other javascript include. For on, I want the jquery framework always ontop, and my own JS files below that.</p> <p class="p1"> For example, I have seen during the first hit of a page the following inclusion:</p> <pre class="p3"> &lt;script id=&quot;staticAssetJavascript0&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript1&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript2&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery-ui.min.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript3&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.easySlider1.7.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript4&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.easySlider1.7.load.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript5&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.autocomplete.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript6&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.bgiframe.min.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript7&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/thickbox-compressed.js&quot;&gt;&lt;/script&gt;</pre> <p class="p1"> And when I just reload the page I get this inclusion order:</p> <pre class="p3"> &lt;script id=&quot;staticAssetJavascript0&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.easySlider1.7.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript1&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.easySlider1.7.load.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript2&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.autocomplete.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript3&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.bgiframe.min.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript4&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/thickbox-compressed.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript5&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript6&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript7&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/assets/javascript/jquery-ui.min.js&quot;&gt;&lt;/script&gt; &lt;script id=&quot;staticAssetJavascript8&quot; type=&quot;text/javascript&quot; src=&quot;/jahia/modules/templates-librecad-aic/javascript/topmenu.js&quot;&gt;&lt;/script&gt;</pre> <p class="p1"> As you can see in the below, on the second page hit the jquery.js and jquery.min.js scripts are all the way at the bottom. I am guessing this has something to do how Jahia caches pages and pages blocks?</p> <p class="p1"> Even when I add this in my templates, the jquery frameworks are at the bottom.</p> <pre class="p3"> &lt;template:addResources type=&quot;javascript&quot; resources=&quot;jquery.min.js,topmenu.js&quot; insert=&quot;true&quot;/&gt;</pre> <p class="p1"> The only way to fix it, is remove jquery from my templates and only add it to my slider templates and use insert=&quot;true&quot; on my slider to make it work reliable and predictable.</p> <p class="p1"> What is the best method to add some javascript frameworks always on top?</p> <p class="p1"> Ries</p>

  • Number of messages  185
    Registration date Jun 7, 2011
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page