CMS MADE SIMPLE FORGE

CMSMSExt

 

[#12429] Changes to jsloader to improve pagespeed ranking

avatar
Created By: Darren Kierman (kierweb)
Date Submitted: 2021-03-10 04:09

Assigned To: Fernando Morgado (JoMorg)
Resolution: Accepted
State: Open
Summary:
Changes to jsloader to improve pagespeed ranking
Detailed Description:
These are changes I make to the "class.jsloader.php" file to increase google
pagespeed ranking, by defer the JS and preloading the CSS - not sure if you want
to include them into the main branch ...

Add defer to the js_fmt variable and add a preload string for CSS (Around line
569)

        $js_fmt = '<script defer src="%s"></script>';
	$css_preload = '<link rel="preload" href="%s" as="style">';
        $css_fmt = '<link type="text/css" rel="stylesheet" href="%s"/>';

Output the preload string for CSS (Around line 910)

       if( $do_css_tag ) {
            $cache_url = CMS_ROOT_URL.'/tmp/cache/'.basename($cache_css);
            $out .= trim(sprintf($css_preload,$cache_url));
            $out .= trim(sprintf($css_fmt,$cache_url));
        }


Hopefully you will consider adding these.


History

Comments
avatar
Date: 2023-03-27 11:09
Posted By: Fernando Morgado (JoMorg)

Implemented in SVN for next release. It will require:
$config['xt_defer_js']                 = TRUE;
$config['xt_preload_css']         = TRUE;
in CMSMSExt/data/cfg.inc
note: keep a backup of that file just in case. It was once overwritten by
mistake. Shouldn't happen again but just in case!
      
Updates

Updated: 2023-03-27 11:12
resolution_id: 5 => 6
assigned_to_id: 100 => 12532

Updated: 2021-03-10 04:09
summary: Changes to jslader to improve pagespeed ranking => Changes to jsloader to improve pagespeed ranking
resolution_id: => 5