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:
Resolution: None
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

Updates

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