+4 votes
in CMS Tips by (34.9k points)
I want to use CDN for CSS and javascript files of the Gallery CMS. There is no plugin for it. Which code(s) should I change for the CDN?

1 Answer

+2 votes
by (157k points)
selected by
 
Best answer

You need to make a small change in the Gallery_View.php present in the "modules/gallery/libraries" folder.

Open the file in an editor and search for the terms "combined/css/$key" and "combined/javascript/$key". The combined CSS and javascript are served from these locations.

You need to add your CDN hostname to these paths to serve CSS and JS files from the CDN.

Here are the changes you need to make.

        if ($type == "css") {
          //$buf .= html::stylesheet("combined/css/$key", "screen,print,projection", true);
          $buf .= html::stylesheet("https://cdn_hostname/css/$key", "screen,print,projection", true);    // Enable CDN
        } else {
          //$buf .= html::script("combined/javascript/$key", true);
          $buf .= html::script("https://cdn_hostname/javascript/$key", true);    // Enable CDN
        }
 

cdn_hostname is your CDN hostname.


...