Join the web development community

Best practise to compress JavaScript and CSS for Drupal 7 website

How can I minify the JavaScript and CSS data size so that it does not use this much bandwidth anymore? Can anybody give a detailed instruction on how to compress the CSS and JavaScript files of a Drupal website?

Junaed's picture

Change the settings from performance

Vote the answer: 
0
No votes yet

Drupal sites come with a performance configuration by default. You will find it at-

site-example.com/admin/config/development/performance.

You will find two performance configuration options here on this page. 

Bandwidth Optimization options>Caching and Bandwidth Optimization.

Select

Aggregate and compress CSS files

&

Aggregate the JavaScript files

Rafsan's picture

Minify and Speedy module can be helpful

Vote the answer: 
0
No votes yet

Use Minify module for Javascript. I will do the same thing like Aggregate and compress CSS files discussed in the previous thread. It takes the help of Google compiler to do so. Along with JavaScripts it also minifies the HTML. It reduces both the core JavaScripts and the custom JS. It is also proved to be beneficial if used to work with Aggregate and compress CSS files & Boost module because in Drupal 7 give you the functionality of adjoining multiple Javascript files by default. Minify will help you improve your site's performance with load time by replacing the whitespace and comments from HTML.

 

Speedy is another module of this kind which will help you take steps to minify the core JavaScripts. You can minify the JavaScripts file which has not already been minified. It comes with a stable release and regular update. The page load time mostly hindered by the front end and this module was designed thinking of this in the first place. It is a counterpart of Aggregate and compress JavaSctips or CSS files but only works for JavaScripts files. It can reduce the file size up to 24% of its original size. Like MInify  It also can replace whitespace and comments even transform functions.