Skip to main content
CSS/JS Minimize Changes (playing) Started by Spuds · · Read 17196 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

CSS/JS Minimize Changes (playing)

ElkArte can minimize and combine CSS and JS files to save on data requests and size.  That is nothing new, its been available since 1.0.

In 2.0 I made changes and you now have the option to minimize and NOT combine -or- minimize and combine the files.  In addition 2.0 will also minimize the inline JS and CSS.  There can be some debate on whether to combine or not, but if your server is running http2 then you are best not combining (IMO)

Another change is that it does a true defer on the JS that has been set as deferred.  In 1.0/1.1 defer simply means the script is added at the end of the html.  With defer, parsing finishes like when we put the script at the end of the body tag, but overall the script execution finishes before, because the script has been downloaded in parallel with the HTML parsing.  So basically it will be somewhat more performant but not as in OMG.  And no you can not simply defer everything.

Thinking that some may want to play with this (on 1.1) and see if they get any improvements, here you go!  (not this will NOT combine, only minimize) Starting with how to do this on the default theme. 

  • Save your existing  /themes/default/Theme.php  in case things go wrong and you tank your site:fire::firefighter:
  • In the admin panel Configuration -> Features and Options -> General ... Turn off  Minify Javascript and CSS files  Save then Clear Hive Cache
  • Place the 3 attached files in your /themes/default folder
  • Go back to admin panel Configuration -> Features and Options -> General ... Turn On Minify Javascript and CSS files

    Simple enough, test things out and make sure nothing breaks (addons especially) ... clear your browser cache just in case as well.

    Now if you are running a custom theme, AND that theme has its own Theme.php file in its theme directory then ask for some help ;) ... its very easy to do, BUT you need to determine what changes were made in the custom Theme.php file and that will be theme dependant.  You will also be adding the attached files to your custom theme directory.

Re: CSS/JS Minimize Changes (playing)

Reply #1

I should have noted in the above post, that if you use a custom theme that does NOT have its own Theme.php file .... Then doing the steps outlined above will enable the new behavior on your custom theme as well (since if it doe NOT have its own Theme.php file, then its using the default one)