Welcome, Guest
Username: Password: Remember me

TOPIC: Duplicated javascript requests

Duplicated javascript requests 3 years 6 months ago #59962

  • medicnick
  • medicnick's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
I'm hoping to speed up my LS by reducing the duplicate js requests. Through a little experimentation I have discovered that common_functions.php has a section that does not appear to be necessary and when commented out, it reduces the js requests in half. In other words, when it is included, LS doubles the js requests.

Can anyone confirm or deny whether this section is required?

In my limited testing with the following commented out, the site appears to render without any issues and was about 20% faster per Firebug net.
//foreach ($js_header_includes as $jsinclude)
    //{
    //    if (substr($jsinclude,0,4) == 'http')
    //        $js_header .= "<script type=\"text/javascript\" src=\"$jsinclude\"></script>\n";
    //    else
    //        $js_header .= "<script type=\"text/javascript\" src=\"".$rooturl."$jsinclude\"></script>\n";
    //}
 
    //foreach ($css_header_includes as $cssinclude)
    //{
    //    $css_header .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".$rooturl.$cssinclude."\" />\n";
    //}

Thanks!
The administrator has disabled public write access.

Re: Duplicated javascript requests 3 years 6 months ago #60056

  • medicnick
  • medicnick's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
I've made a slight adjustment to accommodate the slider js, as the above would not load it. At this point I am leaving it only commented out but it seems to be working well and as mentioned before is slightly faster loading (and forces the ordering of the js and css which addresses Firebug detected issues).

Is there any reason why this shouldn't be considered an improvement?
$js_header = ''; $css_header='';
    /*
   foreach ($js_header_includes as $jsinclude)
    {
        if (substr($jsinclude,0,4) == 'http')
            $js_header .= "<script type=\"text/javascript\" src=\"$jsinclude\"></script>\n";
        else
            $js_header .= "<script type=\"text/javascript\" src=\"".$rooturl."$jsinclude\"></script>\n";
    }
 
    foreach ($css_header_includes as $cssinclude)
    {
        $css_header .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".$rooturl.$cssinclude."\" />\n";
    }
    */
 
    if ( !$embedded )
    {
        $header=  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
        . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"".$surveylanguage."\" lang=\"".$surveylanguage."\"";
        if (getLanguageRTL($surveylanguage))
        {
            $header.=" dir=\"rtl\" ";
        }
        $header.= ">\n\t<head>\n"
 
		. $js_header
		. "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/jquery.js\"></script>\n"
        . "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/jquery-ui.js\"></script>\n"
		. "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/lime-slider.js\"></script>\n"
 
		. $css_header
 
		. "<link href=\"".$rooturl."/scripts/jquery/css/start/jquery-ui.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />\n"
        . "<link href=\"".$rooturl."/scripts/jquery/css/start/lime-progress.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />\n"
        ;
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.188 seconds
Donation Image