i managed to defer loading of JS libraries and also one document ready function, following this post Possible to defer loading of jQuery?
However, I have multiple document ready functions that are placed in the page by different modules (and not on every page). the code I have so far:
echo'
//      deferred loading of jQuery library and
(function() {
 function getScript(url,success){
   var script=document.createElement("script");
   script.src=url;
   var head=document.getElementsByTagName("head")[0],
       done=false;
   script.onload=script.onreadystatechange = function(){
     if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) 
     {
       done=true;
       success();
       script.onload = script.onreadystatechange = null;
       head.removeChild(script);
     }
   };
   head.appendChild(script);
 }
 getScript("lib/jquery/js/jquery-1.4.4.min.js",function(){
   getScript("lib/jquery/js/jquery.tools.min.js",function(){
     $("ul.tabs").tabs("div.panes > .pane",  {
 ';
 if(!isset($params['onclickfunction']) == 'no') {
 echo '
              onClick: function() {
                   var myTab = this.getCurrentTab().text();
                   document.getElementById("titleReplacement").innerHTML = " - " + myTab;
              },
  '; } //end conditional click function
echo '
              effect:"fade",
              fadeInSpeed:800,
              initialIndex:';
if(isset($_GET['tabs'])) { $this_url = $_GET['tabs']; }
else { $this_url = 'some text'; }
if($this_url == $params['tab1']) { echo '0'; }
elseif ($this_url == $params['tab2']) { echo '1'; }
elseif ($this_url == $params['tab3']) { echo '2'; }
//nothing matches? show first tab
else { echo '0'; }
echo  ' })  ;
   });
  })   // possibly another ; here ???
 })();
';
I think this actually works but other document ready functions are trying to run before libraries are loaded. Is there a simple test I could use for the other functions as I am unable to merge them into one function.
cheers