SmartOptimizer
What is SmartOptimizer?
This extra is a MODx version of SmartOptimizer by Ali Farhadi :
"SmartOptimizer (previously named JSmart) is a PHP library that enhances your website performance by optimizing the front end using techniques such as minifying, compression, caching, concatenation and embedding. All the work is done on the fly on demand."
To know more about SmartOptimizer : http://farhadi.ir/works/smartoptimizer.
Requirements
- MODx Revolution 2.0.x or later
- PHP5 or later
Public Releases
Version | Date | Author | Product |
---|---|---|---|
1.0.0-pl
|
April 19, 2012
|
ben_omycode
|
Revolution
|
1.0.0-beta2
|
January 10, 2012
|
ben_omycode
|
Revolution
|
1.0.0-beta1 | December 20, 2011 | ben_omycode | Revolution |
Download
It can be downloaded from within the MODx Revolution manager via Package Management, or from the MODx Extras Repository, here: http://modx.com/extras/package/smartoptimizer
Support, Comments, Development and Bug Reporting
Github : https://github.com/benjamin-vauchel/smartoptimizer
Support/Comments : http://forums.modx.com/thread/72679/support-comments-for-smartoptimizer
Usage : the snippet way
Properties
Name | Description |
---|---|
files
|
path to your CSS or JS files
|
Examples
Before (without SmartOptimizer)
|
After (with SmartOptimizer)
|
---|---|
<!-- Your CSS files --> <link rel="stylesheet" href="assets/css/file1.css"/> <link rel="stylesheet" href="assets/css/file2.css"/> <!-- Your JS files --> <script src="assets/js/file.js"></script> |
<!-- Your CSS files --> <link rel="stylesheet" href="[[SmartOptimizer? &files=`assets/css/file1.css,file2.css`]]"/> <!-- Your JS files --> <script src="[[SmartOptimizer? &files=`assets/js/file.js`]]"></script> |
Usage : the output filter way
Examples
Before (without SmartOptimizer)
|
After (with SmartOptimizer)
|
---|---|
<!-- Your CSS files --> <link rel="stylesheet" href="[[+link_to_css]]"/> <!-- Your JS files --> <script src="[[+link_to_js]]"></script> |
<!-- Your CSS files --> <link rel="stylesheet" href="[[+link_to_css:smartoptimizer]]"/> <!-- Your JS files --> <script src="[[+link_to_js:smartoptimizer]]"></script> |
Usage : the .htaccess way
Add this at the end of your .htaccess :
<IfModule mod_expires.c> <FilesMatch "\.(gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|ico)$"> ExpiresActive On ExpiresDefault "access plus 10 years" </FilesMatch> </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*\.(js|css))$ assets/components/smartoptimizer/connector.php?$1 <IfModule mod_expires.c> RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*\.(js|css|html?|xml|txt))$ assets/components/smartoptimizer/connector.php?$1 </IfModule> <IfModule !mod_expires.c> RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*\.(gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|ico))$ assets/components/smartoptimizer/connector.php?$1 </IfModule> </IfModule> <FilesMatch "\.(gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|ico)$"> FileETag none </FilesMatch>
If you enabled friendly URLs, add also :
RewriteCond %{REQUEST_FILENAME} !(\.css)$ RewriteCond %{REQUEST_FILENAME} !(\.js)$
Before :
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Finally, call your stylesheets and scripts this way :
<link rel="stylesheet" href="assets/css/file1.css,file2.css"/> <link rel="stylesheet" href="assets/css/file1.css,file2.css"/>
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).