Introduction

Smart compress module is a user friendly module that allows user to compress and format css and js files. It allows all css ( .css, .less and .scss ) and js files for format.

Compatibility

EE Compatible Version: EE3, EE4, EE5, EE6.

Some features of Smart Compress are listed below:

  1. Easy to Install and use.
  2. Support LESS and SCSS files.
  3. There are many css formatter available. ( Expanded, Nested, Compact, Compressed, Crunched ) that allows css file formatting.
  4. Minify or Beautify js files and add as many files you want to add in single list.
  5. You can manage file name and server path where you want to save file.
  6. Create cache for a specific time duration.
  7. Allow file selection based on enter server path. You just need to check the files that you want to compress or format.

Note: We are not providing support for EE3.

Installation

Follow below steps to install Smart Compress version:

EE3, EE4, EE5, EE6 :

  1. Download and Extract ZIP file of the module. (We recommend to use latest version.)
  2. Copy “SmartCompress > system > user > addons > smart_compress” folder to “Your Site > system > user> addons” Folder.
  3. Copy “SmartCompress > themes > user > smart_compress” folder to “Your Site > themes > user” Folder.
  4. Login to backend panel with Super admin credentials.
  5. Go to “Developer > Add-Ons” and Install Smart Compress module.

Note: If you purchased the addon from Devot:ee then you can get the license key from the licenses tab in your profile.

Files to Compress

  1. To add all css or js files to format in single file, You have to create an input. That is all files to select and add in single place. To do so, create new settings under Files to Compress section.This would be basically an Input of files.You can create settings from multiple places.

    Fill the required fields, Add a valid server path (Where all your css or js presents) and hit compile button. It will fire an AJAX call and get you the list of all the css/js files present in that directory. (No matter how many sub directories you have, it will bring all the files.)Enter any name in the name field, select type in type field and enter the server folder path on which files are exist.Once you hit compile button, you will have list of files (That matches your extension you select.)

    Note: It is recommended not to select main jquery.js file. JQuery should always be at the top of all scripts. Always use JQuery file individually and not merge with our addon.

    After fill out the form, Record will show under “Files to compress” listing in table. You can either delete it or edit it.
  2. All form fields are described below:

      1. Title:

    Title is to remember which inputs have been created. (It will be useful to find and select inputs in compressed output form.)

      1. Type:

    You have to select which file type you want to add in this particular output.

      1. Add folder path:

    Add folder path where all file exists.

      1. Files:

    Based on server path all files will list here based on the type that you have selected before.

Compressed Output

Step 1 Would be to create input settings by creating settings under “Files to Compress” section.
This is step 2 (Last step) to create a single file with all the css/js inside.
After creating “Files to Compress”, You can create output settings from here. Click on create new settings to get a form. There is many places you can create this settings.

All form fields are described as below:

    1. Title:

File title is for remembering what output is created.

    1. Short name :

Final merged css / js output file will be named from this short name. This field will use to give file name of newly generated output file.

    1. Type:

You have to select which file type you want to add in this particular output. Based on type, “Add Files to compress with this output” section will change to view compress input list.

    1. Format:You can set output format in below typesAvailable Formats for CSS:
      1. Expanded
      2. Nested
      3. Compact
      4. Compressed
      5. Crunched

      Available Formats for JS:

      1. Minify
      2. Beautify
    2. Server Path:

Add the server path where you want to create your file. Make sure you don’t add File name. You only need to enter the path till folder.

    1. Path URL:

Add URL path where you want to create your file. Make sure you don’t add File name. You only need to enter path till folder.

    1. Add Files to compress with this output:

It comes from “Files to compress” listing based on the type field selected above.

    1. Cache:

We offer to save final output in cache so there will be no process on each page reload. Pass how many minutes you want to cache the output file.


You can see all outputs you save on listing page. (Or we can say index page of addon settings.)

Custom Sidebar

We provide one “customSidebar” function in the MCP file. You can add more menus in the sidebar of the addon using this function.

/* To get dynamic menu in the addon */    
   function customSidebar(){
       $sidebar = ee('CP/Sidebar')->make();
       $this->navSettings  = $sidebar->addHeader('Test Link', '');
   }

Template Tags

{exp:smart_compress}

Parameters

  1. id
  2. short_name
  3. url_only
  4. show_error

Following Parameters can be use in Smart Compress tag.

id

Id of your “Compressed Output” list. You can pass any single ID to get css/js file URL of particular output.

Note: You can get output URL by either short_name or ID.

Example:

 id="1"

short_name

Id of your “Compressed Output” list. You can pass any short name to get css/js file URL of particular output.

Note: You can get output URL by either short_name or ID.

Example:

 short_name="short_name_of_output"

url_only (For single tag. Not for tagdata.)

If set “yes”, output would be without any HTML css/js declaration. Tag will return only URL.

Example:

 id="1" url_only="yes" 
     OUTPUT: http://www.abc.com/cssfiles.css

If Set to “NO”, output would be with HTML css/js declaration.

Example:

 id="1" 
     OUTPUT: <link rel="stylesheet" type="text/css" href="http://www.abc.com/cssfiles.css">

show_error

If set “yes”, It will return error if output fails to generate files. Basically one can use it to debug the output file.

Example:

 show_error="yes"

Fields

  1. output :
    It will give you URL of css or js file.

Examples :

{exp:smart_compress id="2"}
        <link rel="stylesheet" type="text/css" href="{output}">
    {/exp:smart_compress}
<link rel="stylesheet" type="text/css" href="{exp:smart_compress id='2' url_only='yes'}">
<script type="text/javascript" src="{exp:smart_compress id='1' url_only='yes'}"> </script>
{exp:smart_compress id='2'}
    //No need to pass style declaration as it will generate automatically via Addon.

Changelog

V1.0.0

  • Initial release.
    Note : There is no Changelog yet.

V2.0.0

  • Updated the license verification process and setup so please update the license in your addon.

V3.0.0

  • Provided support of EE6.