Hello,

I've modified a page so instead of putting all the
<script src ... for all the plugins I use (rating+dimension+meta
+tablesorter...)

in the head, I only kept the jquery in the head and loaded the others
like that (exemple for tablesorter):

    <script type="text/javascript">
        function initTableSorterRelated() {....}
        jQuery(function(){
          if(!$.isFunction($.fn['tablesorter'])) {
            jQuery.getScript('/path/jquery.rating.js', function() {
            initTableSorterRelated ();
           });
         }
         else
           initTableSorterRelated ();
        ... do the same for the other plugins

(I do the isFunction test as the plugin can already be loaded for
other reasons)

It feels faster !

Looking at Firebug, it looks like nothing happen until all the scripts
in the head are loaded, so delaying the loading into the ready
function speeds it. Of course, it doesn't change the amount of things
the browser has to load, but it looks like it delays it until it has
started displaying the page, so it feels like it's faster.

Does it make sense ? Have some of you seen something like that ?

I'd like to write a getScriptOnce (scr, callback)
or init (src,init)

But adding another plugin to my long list to speed it seems not
logical to me. I might keep it inline.

Any suggestion ?

A last technical question : How to check if a script is already loaded
(is there a list of all the script loaded, no matter if it's in the
<head> or via getScript?)

X+

Reply via email to