Apptrian_Minify_HTML_CSS_JS - Version 1.3.0

Version Notes

+ Minification of CSS and JS files with a button click in extension configuration
* Eliminated dependency on Mage_Page_Block_Html_Head block (Extension does not rewrite this block nor any other any more)
- Versioning of CSS and JS files

Download this release

Release Info

Developer Apptrian
Extension Apptrian_Minify_HTML_CSS_JS
Version 1.3.0
Comparing to
See all releases


Code changes from version 1.2.0 to 1.3.0

app/code/community/Apptrian/Minify/Block/Adminhtml/Button/Minify.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_Minify
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2015 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Apptrian_Minify_Block_Adminhtml_Button_Minify extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ /**
12
+ * Import static blocks
13
+ *
14
+ * @param Varien_Data_Form_Element_Abstract $element
15
+ * @return String
16
+ */
17
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
18
+ {
19
+
20
+ $elementOriginalData = $element->getOriginalData();
21
+
22
+ if (isset($elementOriginalData['label'])) {
23
+ $buttonLabel = $elementOriginalData['label'];
24
+ } else {
25
+ return '<div>Button label was not specified</div>';
26
+ }
27
+
28
+ $url = Mage::helper('adminhtml')->getUrl(
29
+ 'apptrian_minify/adminhtml_minify/process');
30
+
31
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
32
+ ->setType('button')
33
+ ->setClass('apptrian-minify-admin-button-minify')
34
+ ->setLabel($buttonLabel)
35
+ ->setOnClick("setLocation('$url')")
36
+ ->toHtml();
37
+
38
+ return $html;
39
+
40
+ }
41
+ }
app/code/community/Apptrian/Minify/Block/Page/Html/Head.php DELETED
@@ -1,198 +0,0 @@
1
- <?php
2
- /**
3
- * @category Apptrian
4
- * @package Apptrian_Minify
5
- * @author Apptrian
6
- * @copyright Copyright (c) 2015 Apptrian (http://www.apptrian.com)
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- class Apptrian_Minify_Block_Page_Html_Head extends Mage_Page_Block_Html_Head
10
- {
11
-
12
- /**
13
- * Override method.
14
- *
15
- * @param string $format
16
- * @param array $staticItems
17
- * @param array $skinItems
18
- * @param string $mergeCallback
19
- * @return string
20
- */
21
- protected function &_prepareStaticAndSkinElements($format, array $staticItems, array $skinItems,
22
- $mergeCallback = null)
23
- {
24
- $designPackage = Mage::getDesign();
25
- $baseJsUrl = Mage::getBaseUrl('js');
26
- $items = array();
27
- if ($mergeCallback && !is_callable($mergeCallback)) {
28
- $mergeCallback = null;
29
- }
30
-
31
- // get static files from the js folder, no need in lookups
32
- foreach ($staticItems as $params => $rows) {
33
- foreach ($rows as $name) {
34
- $items[$params][] = $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $name : $baseJsUrl . $name;
35
- }
36
- }
37
-
38
- // lookup each file basing on current theme configuration
39
- foreach ($skinItems as $params => $rows) {
40
- foreach ($rows as $name) {
41
- $items[$params][] = $mergeCallback ? $designPackage->getFilename($name, array('_type' => 'skin'))
42
- : $designPackage->getSkinUrl($name, array());
43
- }
44
- }
45
-
46
- $html = '';
47
- foreach ($items as $params => $rows) {
48
- // attempt to merge
49
- $mergedUrl = false;
50
- if ($mergeCallback) {
51
- $mergedUrl = call_user_func($mergeCallback, $rows);
52
- }
53
- // render elements
54
- $params = trim($params);
55
- $params = $params ? ' ' . $params : '';
56
- if ($mergedUrl) {
57
-
58
- $minifiedFileUrl = $this->minifyCssJs($format, $mergedUrl);
59
-
60
- $html .= sprintf($format, $minifiedFileUrl, $params);
61
-
62
- } else {
63
- foreach ($rows as $src) {
64
- $html .= sprintf($format, $src, $params);
65
- }
66
- }
67
- }
68
- return $html;
69
- }
70
-
71
- /**
72
- * Method minifies .css and .js files.
73
- * (Custom method not from original block.)
74
- *
75
- * @param string $format
76
- * @param string $mergedUrl
77
- * @return string
78
- */
79
- public function minifyCssJs($format, $mergedUrl)
80
- {
81
-
82
- $baseDirMedia = Mage::getBaseDir('media');
83
- $baseUrlMedia = Mage::getBaseUrl('media');
84
-
85
- $relativeUrl = str_replace($baseUrlMedia, '', $mergedUrl);
86
-
87
- $relativeUrlPathArray = explode('/', $relativeUrl);
88
-
89
- $relativePath = implode(DS, $relativeUrlPathArray);
90
-
91
- $originalFile = array_pop($relativeUrlPathArray);
92
-
93
- $originalFileRealPath = $baseDirMedia . DS . $relativePath;
94
-
95
- // CSS
96
- if (strpos($format, '<link') === 0) {
97
-
98
- if (!Mage::getStoreConfigFlag('apptrian_minify/general/minify_css')) {
99
- return $mergedUrl;
100
- }
101
-
102
- $minifiedFilename = $this->getMinifiedFilename($originalFile, 'css');
103
- $minifiedFileRealPath = $this->getMinifiedFileRealPath($baseDirMedia, $minifiedFilename, $relativeUrlPathArray);
104
- $minifiedFileUrl = $this->getMinifiedFileUrl($baseUrlMedia, $minifiedFilename, $relativeUrlPathArray);
105
-
106
- if (!file_exists($minifiedFileRealPath)) {
107
-
108
- if (file_put_contents($minifiedFileRealPath, Minify::combine($originalFileRealPath)) === false) {
109
-
110
- Mage::log('Minified CSS file could not be written.');
111
-
112
- $minifiedFileUrl = $mergedUrl;
113
-
114
- }
115
-
116
- }
117
-
118
- }
119
-
120
- // JS
121
- if (strpos($format, '<script') === 0) {
122
-
123
- if (!Mage::getStoreConfigFlag('apptrian_minify/general/minify_js')) {
124
- return $mergedUrl;
125
- }
126
-
127
- $minifiedFilename = $this->getMinifiedFilename($originalFile, 'js');
128
- $minifiedFileRealPath = $this->getMinifiedFileRealPath($baseDirMedia, $minifiedFilename, $relativeUrlPathArray);
129
- $minifiedFileUrl = $this->getMinifiedFileUrl($baseUrlMedia, $minifiedFilename, $relativeUrlPathArray);
130
-
131
- if (!file_exists($minifiedFileRealPath)) {
132
-
133
- if (file_put_contents($minifiedFileRealPath, Minify::combine($originalFileRealPath)) === false) {
134
-
135
- Mage::log('Minified JS file could not be written.');
136
-
137
- $minifiedFileUrl = $mergedUrl;
138
-
139
- }
140
-
141
- }
142
-
143
- }
144
-
145
- return $minifiedFileUrl;
146
-
147
- }
148
-
149
- /**
150
- * Generates filename of minified file.
151
- * (Custom method not from original block.)
152
- *
153
- * @param string $file
154
- * @param string $type
155
- * @return string
156
- */
157
- public function getMinifiedFilename($file, $type)
158
- {
159
- if ($type == 'css') {
160
- $v = Mage::getStoreConfig('apptrian_minify/general/css_version');
161
- } else {
162
- $v = Mage::getStoreConfig('apptrian_minify/general/js_version');
163
- }
164
-
165
- return hash('md5', $file . $v) . '.' . $type;
166
- }
167
-
168
- /**
169
- * Returns real path of minified file.
170
- * (Custom method not from original block.)
171
- *
172
- * @param string $baseDirMedia
173
- * @param string $minifiedFilename
174
- * @param array $relativeUrlPathArray
175
- * @return string
176
- */
177
- public function getMinifiedFileRealPath($baseDirMedia, $minifiedFilename, $relativeUrlPathArray)
178
- {
179
- $relativePath = implode(DS, $relativeUrlPathArray);
180
- return $baseDirMedia . DS . $relativePath . DS . $minifiedFilename;
181
- }
182
-
183
- /**
184
- * Returns url of minified file.
185
- * (Custom method not from original block.)
186
- *
187
- * @param string $baseUrlMedia
188
- * @param string $minifiedFilename
189
- * @param array $relativeUrlPathArray
190
- * @return string
191
- */
192
- public function getMinifiedFileUrl($baseUrlMedia, $minifiedFilename, $relativeUrlPathArray)
193
- {
194
- $relativeUrl = implode('/', $relativeUrlPathArray);
195
- return $baseUrlMedia . $relativeUrl . '/' . $minifiedFilename;
196
- }
197
-
198
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Apptrian/Minify/Helper/Data.php CHANGED
@@ -9,6 +9,8 @@
9
  class Apptrian_Minify_Helper_Data extends Mage_Core_Helper_Abstract
10
  {
11
 
 
 
12
  /**
13
  * Returns extension version.
14
  *
@@ -18,5 +20,58 @@ class Apptrian_Minify_Helper_Data extends Mage_Core_Helper_Abstract
18
  {
19
  return (string) Mage::getConfig()->getNode()->modules->Apptrian_Minify->version;
20
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
 
22
  }
9
  class Apptrian_Minify_Helper_Data extends Mage_Core_Helper_Abstract
10
  {
11
 
12
+ protected $paths = null;
13
+
14
  /**
15
  * Returns extension version.
16
  *
20
  {
21
  return (string) Mage::getConfig()->getNode()->modules->Apptrian_Minify->version;
22
  }
23
+
24
+
25
+ public function getPaths()
26
+ {
27
+ if ($this->paths === null) {
28
+ $list = array();
29
+ $baseDirMedia = Mage::getBaseDir('media');
30
+ $list[] = $baseDirMedia . DS . 'css';
31
+ $list[] = $baseDirMedia . DS . 'css_secure';
32
+ $list[] = $baseDirMedia . DS . 'js';
33
+
34
+ $this->paths = $list;
35
+ }
36
+
37
+ return $this->paths;
38
+ }
39
+
40
+ /**
41
+ * Minifies CSS and JS files.
42
+ *
43
+ */
44
+ public function process()
45
+ {
46
+
47
+ foreach ($this->getPaths() as $path) {
48
+
49
+ $iterator = new RecursiveIteratorIterator(
50
+ new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
51
+
52
+ foreach ($iterator as $filename => $file) {
53
+
54
+ if ($file->isFile() && preg_match( '/^.+\.(css|js)$/i', $file->getFilename())) {
55
+
56
+ $filePath = $file->getRealPath();
57
+ if (!is_writable($filePath)) {
58
+ Mage::log('Minification failed for ' . $filePath . ' File is not writable.');
59
+ continue;
60
+ }
61
+
62
+ if (file_put_contents($filePath, Minify::combine($filePath), LOCK_EX) === false) {
63
+
64
+ Mage::log('Minification failed for ' . $filePath);
65
+
66
+ }
67
+
68
+ }
69
+
70
+ }
71
+
72
+ }
73
+
74
+ }
75
 
76
+
77
  }
app/code/community/Apptrian/Minify/Model/Config/Version.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * @category Apptrian
4
- * @package Apptrian_Minify
5
- * @author Apptrian
6
- * @copyright Copyright (c) 2015 Apptrian (http://www.apptrian.com)
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- class Apptrian_Minify_Model_Config_Version extends Mage_Core_Model_Config_Data
10
- {
11
-
12
- public function _beforeSave()
13
- {
14
-
15
- $result = $this->validate();
16
-
17
- if ($result !== true) {
18
-
19
- Mage::throwException(implode("\n", $result));
20
-
21
- }
22
-
23
- return parent::_beforeSave();
24
-
25
- }
26
-
27
- public function validate()
28
- {
29
-
30
- $errors = array();
31
- $helper = Mage::helper('apptrian_minify');
32
- $value = $this->getValue();
33
-
34
- if (!Zend_Validate::is($value, 'Regex', array('pattern' => '/^[\p{L}\p{N}_,;:!&#\+\*\$\?\|\'\.\-\ \/]*$/iu'))) {
35
- $errors[] = $helper->__('One or more of Version fields are invalid.');
36
- }
37
-
38
- if (empty($errors)) {
39
- return true;
40
- }
41
-
42
- return $errors;
43
-
44
- }
45
-
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Apptrian/Minify/controllers/Adminhtml/MinifyController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_Minify
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2015 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Apptrian_Minify_Adminhtml_MinifyController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+
12
+ public function processAction()
13
+ {
14
+
15
+ $helper = Mage::helper('apptrian_minify');
16
+
17
+ try {
18
+
19
+ $helper->process();
20
+
21
+ $message = $this->__('Minification operations completed successfully.');
22
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
23
+
24
+ } catch (Exception $e) {
25
+
26
+ $message = $this->__('Minification failed.');
27
+ Mage::getSingleton('adminhtml/session')->addError($message);
28
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
29
+
30
+ }
31
+
32
+ $url = Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit/section/apptrian_minify');
33
+ Mage::app()->getResponse()->setRedirect($url);
34
+
35
+ }
36
+
37
+ }
app/code/community/Apptrian/Minify/etc/config.xml CHANGED
@@ -11,7 +11,7 @@
11
  <config>
12
  <modules>
13
  <Apptrian_Minify>
14
- <version>1.2.0</version>
15
  </Apptrian_Minify>
16
  </modules>
17
  <global>
@@ -29,11 +29,6 @@
29
  <apptrian_minify>
30
  <class>Apptrian_Minify_Block</class>
31
  </apptrian_minify>
32
- <page>
33
- <rewrite>
34
- <html_head>Apptrian_Minify_Block_Page_Html_Head</html_head>
35
- </rewrite>
36
- </page>
37
  </blocks>
38
  <resources>
39
  <apptrian_minify_setup>
@@ -52,10 +47,6 @@
52
  <minify_html>0</minify_html>
53
  <max_minification>0</max_minification>
54
  <compatibility>0</compatibility>
55
- <minify_css>0</minify_css>
56
- <css_version></css_version>
57
- <minify_js>0</minify_js>
58
- <js_version></js_version>
59
  </general>
60
  </apptrian_minify>
61
  </default>
@@ -79,6 +70,17 @@
79
  </controller_action_postdispatch>
80
  </events>
81
  </frontend>
 
 
 
 
 
 
 
 
 
 
 
82
  <adminhtml>
83
  <acl>
84
  <resources>
11
  <config>
12
  <modules>
13
  <Apptrian_Minify>
14
+ <version>1.3.0</version>
15
  </Apptrian_Minify>
16
  </modules>
17
  <global>
29
  <apptrian_minify>
30
  <class>Apptrian_Minify_Block</class>
31
  </apptrian_minify>
 
 
 
 
 
32
  </blocks>
33
  <resources>
34
  <apptrian_minify_setup>
47
  <minify_html>0</minify_html>
48
  <max_minification>0</max_minification>
49
  <compatibility>0</compatibility>
 
 
 
 
50
  </general>
51
  </apptrian_minify>
52
  </default>
70
  </controller_action_postdispatch>
71
  </events>
72
  </frontend>
73
+ <admin>
74
+ <routers>
75
+ <apptrian_minify>
76
+ <use>admin</use>
77
+ <args>
78
+ <module>Apptrian_Minify</module>
79
+ <frontName>apptrian_minify</frontName>
80
+ </args>
81
+ </apptrian_minify>
82
+ </routers>
83
+ </admin>
84
  <adminhtml>
85
  <acl>
86
  <resources>
app/code/community/Apptrian/Minify/etc/system.xml CHANGED
@@ -60,16 +60,17 @@
60
  </info>
61
  </fields>
62
  </about>
63
- <general translate="label">
64
  <label>General</label>
65
  <frontend_type>text</frontend_type>
66
  <sort_order>2</sort_order>
67
  <show_in_default>1</show_in_default>
68
  <show_in_website>1</show_in_website>
69
  <show_in_store>1</show_in_store>
 
70
  <fields>
71
  <heading_html translate="label">
72
- <label>HTML Settings</label>
73
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
74
  <sort_order>1</sort_order>
75
  <show_in_default>1</show_in_default>
@@ -113,70 +114,24 @@
113
  <minify_html>1</minify_html>
114
  </depends>
115
  </compatibility>
116
- <heading_css translate="label">
117
- <label>CSS Settings</label>
118
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
119
  <sort_order>5</sort_order>
120
  <show_in_default>1</show_in_default>
121
- <show_in_website>1</show_in_website>
122
- <show_in_store>1</show_in_store>
123
- </heading_css>
124
- <minify_css translate="label comment">
125
- <label>Minify CSS</label>
126
- <frontend_type>select</frontend_type>
127
- <source_model>adminhtml/system_config_source_yesno</source_model>
128
  <sort_order>6</sort_order>
129
  <show_in_default>1</show_in_default>
130
- <show_in_website>1</show_in_website>
131
- <show_in_store>1</show_in_store>
132
- <comment><![CDATA[Enables or disables CSS minification.<br />WARNING! Before you enable this option you must have valid CSS code on all of the pages on your site. In order for minification to work you must enable Admin>System>Configuration>Developer>CSS Settings>Merge CSS Files.]]></comment>
133
- </minify_css>
134
- <css_version translate="label comment tooltip">
135
- <label>Merged CSS Version</label>
136
- <frontend_type>text</frontend_type>
137
- <backend_model>apptrian_minify/config_version</backend_model>
138
- <sort_order>7</sort_order>
139
- <show_in_default>1</show_in_default>
140
- <show_in_website>1</show_in_website>
141
- <show_in_store>1</show_in_store>
142
- <comment>Merged .css file version.</comment>
143
- <tooltip><![CDATA[If you are using <strong>browser caching</strong> then you can use "versioning" technique to force browsers to load new version of merged .css file. This "version" can be any string you want and it will not be visible. It is used for generating new hashed name of .css file. The best practice is to use numbers and then increment on every new "version".]]></tooltip>
144
- <depends>
145
- <minify_css>1</minify_css>
146
- </depends>
147
- </css_version>
148
- <heading_js translate="label">
149
- <label>JS Settings</label>
150
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
151
- <sort_order>8</sort_order>
152
- <show_in_default>1</show_in_default>
153
- <show_in_website>1</show_in_website>
154
- <show_in_store>1</show_in_store>
155
- </heading_js>
156
- <minify_js translate="label comment">
157
- <label>Minify JavaScript</label>
158
- <frontend_type>select</frontend_type>
159
- <source_model>adminhtml/system_config_source_yesno</source_model>
160
- <sort_order>9</sort_order>
161
- <show_in_default>1</show_in_default>
162
- <show_in_website>1</show_in_website>
163
- <show_in_store>1</show_in_store>
164
- <comment><![CDATA[Enables or disables JavaScript minification.<br />WARNING! Before you enable this option you must have valid JS code on all of the pages on your site. In order for minification to work you must enable Admin>System>Configuration>Developer>JavaScript Settings>Merge JavaScript Files.]]></comment>
165
- </minify_js>
166
- <js_version translate="label comment tooltip">
167
- <label>Merged JavaScript Version</label>
168
- <frontend_type>text</frontend_type>
169
- <backend_model>apptrian_minify/config_version</backend_model>
170
- <sort_order>10</sort_order>
171
- <show_in_default>1</show_in_default>
172
- <show_in_website>1</show_in_website>
173
- <show_in_store>1</show_in_store>
174
- <comment>Merged .js file version.</comment>
175
- <tooltip><![CDATA[If you are using <strong>browser caching</strong> then you can use "versioning" technique to force browsers to load new version of merged .js file. This "version" can be any string you want and it will not be visible. It is used for generating new hashed name of .js file. The best practice is to use numbers and then increment on every new "version".]]></tooltip>
176
- <depends>
177
- <minify_js>1</minify_js>
178
- </depends>
179
- </js_version>
180
  </fields>
181
  </general>
182
  </groups>
60
  </info>
61
  </fields>
62
  </about>
63
+ <general translate="label comment">
64
  <label>General</label>
65
  <frontend_type>text</frontend_type>
66
  <sort_order>2</sort_order>
67
  <show_in_default>1</show_in_default>
68
  <show_in_website>1</show_in_website>
69
  <show_in_store>1</show_in_store>
70
+ <comment><![CDATA[1. Enable <strong>System > Configuration > Developer > CSS Settings > Merge CSS Files</strong><br />2. Enable <strong>System > Configuration > Developer > JavaScript Settings > Merge JavaScript Files</strong><br />3. Flush and Refresh Magento cache <strong>System > Cache Management</strong><br />4. Visit several pages of your site on the frontend and wait for them to fully load. (Visit home page, one CMS page, one category page, one product page, cart page, and checkout page. This is done so Magento default merger can merge CSS and JS files, and some extensions add CSS and/or JS files only on specific pages not globally.)<br />5. Click <strong>Minify</strong> button and wait for CSS/JS files to be minified.<br />6. If you are using <strong>Expires</strong> header for CSS and JS files remember to empty your web browser's cache.<br />7. If you are using <strong>CDN</strong> make sure you flush/empty CDN cache.]]></comment>
71
  <fields>
72
  <heading_html translate="label">
73
+ <label>Minify HTML Settings</label>
74
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
75
  <sort_order>1</sort_order>
76
  <show_in_default>1</show_in_default>
114
  <minify_html>1</minify_html>
115
  </depends>
116
  </compatibility>
117
+ <heading_minify_files translate="label">
118
+ <label>Minify CSS and JavaScript Files</label>
119
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
120
  <sort_order>5</sort_order>
121
  <show_in_default>1</show_in_default>
122
+ <show_in_website>0</show_in_website>
123
+ <show_in_store>0</show_in_store>
124
+ </heading_minify_files>
125
+ <minify_files translate="label comment">
126
+ <label>Minify</label>
127
+ <frontend_type>button</frontend_type>
128
+ <frontend_model>apptrian_minify/adminhtml_button_minify</frontend_model>
129
  <sort_order>6</sort_order>
130
  <show_in_default>1</show_in_default>
131
+ <show_in_website>0</show_in_website>
132
+ <show_in_store>0</show_in_store>
133
+ <comment><![CDATA[WARNING! Follow instructions on the top.]]></comment>
134
+ </minify_files>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  </fields>
136
  </general>
137
  </groups>
app/locale/en_US/Apptrian_Minify.csv CHANGED
@@ -1,10 +1,12 @@
1
- "One or more of Version fields are invalid.","One or more of Version fields are invalid."
 
2
  "Info","Info"
3
  "Minify HTML CSS JS","Minify HTML CSS JS"
4
  "Apptrian Extensions","Apptrian Extensions"
5
  "About","About"
6
  "General","General"
7
- "HTML Settings","HTML Settings"
 
8
  "Minify HTML","Minify HTML"
9
  "Enables or disables HTML minification.<br />WARNING! Before you enable this option you must have valid HTML code on all of the pages on your site. Use W3C Validator to check.","Enables or disables HTML minification.<br />WARNING! Before you enable this option you must have valid HTML code on all of the pages on your site. Use W3C Validator to check."
10
  "Enable Maximum Minification","Enable Maximum Minification"
@@ -12,15 +14,6 @@
12
  "If you enable this option all multiple spaces will be eliminated and replaced with one space. All new line characters will be substituted with one space character. Your entire code will be on one line. This is not recommended, you should keep this option disabled.","If you enable this option all multiple spaces will be eliminated and replaced with one space. All new line characters will be substituted with one space character. Your entire code will be on one line. This is not recommended, you should keep this option disabled."
13
  "Enable Cache Compatibility Mode","Enable Cache Compatibility Mode"
14
  "Enables or disables Cache Compatibility Mode.<br />WARNING! You should enable this if you use third party FPC or Varnish cache extensions.","Enables or disables Cache Compatibility Mode.<br />WARNING! You should enable this if you use third party FPC or Varnish cache extensions."
15
- "CSS Settings","CSS Settings"
16
- "Minify CSS","Minify CSS"
17
- "Enables or disables CSS minification.<br />WARNING! Before you enable this option you must have valid CSS code on all of the pages on your site. In order for minification to work you must enable Admin>System>Configuration>Developer>CSS Settings>Merge CSS Files.","Enables or disables CSS minification.<br />WARNING! Before you enable this option you must have valid CSS code on all of the pages on your site. In order for minification to work you must enable Admin>System>Configuration>Developer>CSS Settings>Merge CSS Files."
18
- "Merged CSS Version","Merged CSS Version"
19
- "Merged .css file version.","Merged .css file version."
20
- "If you are using <strong>browser caching</strong> then you can use ""versioning"" technique to force browsers to load new version of merged .css file. This ""version"" can be any string you want and it will not be visible. It is used for generating new hashed name of .css file. The best practice is to use numbers and then increment on every new ""version"".","If you are using <strong>browser caching</strong> then you can use ""versioning"" technique to force browsers to load new version of merged .css file. This ""version"" can be any string you want and it will not be visible. It is used for generating new hashed name of .css file. The best practice is to use numbers and then increment on every new ""version""."
21
- "JS Settings","JS Settings"
22
- "Minify JavaScript","Minify JavaScript"
23
- "Enables or disables JavaScript minification.<br />WARNING! Before you enable this option you must have valid JS code on all of the pages on your site. In order for minification to work you must enable Admin>System>Configuration>Developer>JavaScript Settings>Merge JavaScript Files.","Enables or disables JavaScript minification.<br />WARNING! Before you enable this option you must have valid JS code on all of the pages on your site. In order for minification to work you must enable Admin>System>Configuration>Developer>JavaScript Settings>Merge JavaScript Files."
24
- "Merged JavaScript Version","Merged JavaScript Version"
25
- "Merged .js file version.","Merged .js file version."
26
- "If you are using <strong>browser caching</strong> then you can use ""versioning"" technique to force browsers to load new version of merged .js file. This ""version"" can be any string you want and it will not be visible. It is used for generating new hashed name of .js file. The best practice is to use numbers and then increment on every new ""version"".","If you are using <strong>browser caching</strong> then you can use ""versioning"" technique to force browsers to load new version of merged .js file. This ""version"" can be any string you want and it will not be visible. It is used for generating new hashed name of .js file. The best practice is to use numbers and then increment on every new ""version""."
1
+ "Minification operations completed successfully.","Minification operations completed successfully."
2
+ "Minification failed.","Minification failed."
3
  "Info","Info"
4
  "Minify HTML CSS JS","Minify HTML CSS JS"
5
  "Apptrian Extensions","Apptrian Extensions"
6
  "About","About"
7
  "General","General"
8
+ "1. Enable <strong>System > Configuration > Developer > CSS Settings > Merge CSS Files</strong><br />2. Enable <strong>System > Configuration > Developer > JavaScript Settings > Merge JavaScript Files</strong><br />3. Flush and Refresh Magento cache <strong>System > Cache Management</strong><br />4. Visit several pages of your site on the frontend and wait for them to fully load. (Visit home page, one CMS page, one category page, one product page, cart page, and checkout page. This is done so Magento default merger can merge CSS and JS files, and some extensions add CSS and/or JS files only on specific pages not globally.)<br />5. Click <strong>Minify</strong> button and wait for CSS/JS files to be minified.<br />6. If you are using <strong>Expires</strong> header for CSS and JS files remember to empty your web browser's cache.<br />7. If you are using <strong>CDN</strong> make sure you flush/empty CDN cache.","1. Enable <strong>System > Configuration > Developer > CSS Settings > Merge CSS Files</strong><br />2. Enable <strong>System > Configuration > Developer > JavaScript Settings > Merge JavaScript Files</strong><br />3. Flush and Refresh Magento cache <strong>System > Cache Management</strong><br />4. Visit several pages of your site on the frontend and wait for them to fully load. (Visit home page, one CMS page, one category page, one product page, cart page, and checkout page. This is done so Magento default merger can merge CSS and JS files, and some extensions add CSS and/or JS files only on specific pages not globally.)<br />5. Click <strong>Minify</strong> button and wait for CSS/JS files to be minified.<br />6. If you are using <strong>Expires</strong> header for CSS and JS files remember to empty your web browser's cache.<br />7. If you are using <strong>CDN</strong> make sure you flush/empty CDN cache."
9
+ "Minify HTML Settings","Minify HTML Settings"
10
  "Minify HTML","Minify HTML"
11
  "Enables or disables HTML minification.<br />WARNING! Before you enable this option you must have valid HTML code on all of the pages on your site. Use W3C Validator to check.","Enables or disables HTML minification.<br />WARNING! Before you enable this option you must have valid HTML code on all of the pages on your site. Use W3C Validator to check."
12
  "Enable Maximum Minification","Enable Maximum Minification"
14
  "If you enable this option all multiple spaces will be eliminated and replaced with one space. All new line characters will be substituted with one space character. Your entire code will be on one line. This is not recommended, you should keep this option disabled.","If you enable this option all multiple spaces will be eliminated and replaced with one space. All new line characters will be substituted with one space character. Your entire code will be on one line. This is not recommended, you should keep this option disabled."
15
  "Enable Cache Compatibility Mode","Enable Cache Compatibility Mode"
16
  "Enables or disables Cache Compatibility Mode.<br />WARNING! You should enable this if you use third party FPC or Varnish cache extensions.","Enables or disables Cache Compatibility Mode.<br />WARNING! You should enable this if you use third party FPC or Varnish cache extensions."
17
+ "Minify CSS and JavaScript Files","Minify CSS and JavaScript Files"
18
+ "Minify","Minify"
19
+ "WARNING! Follow instructions on the top.","WARNING! Follow instructions on the top."
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,19 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apptrian_Minify_HTML_CSS_JS</name>
4
- <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Minify HTML CSS JS including inline CSS/JS and speed up your site. Works with default Magento CSS/JS merger.</summary>
10
  <description>Apptrian Minify HTML CSS JS is a very small and efficient extension. It will minify HTML including inline CSS and JS code. Minification of CSS and JS files is compatible with default Magento CSS and JS file merger. There are no complex setups nor query strings on minified CSS and JS files. Extension is very easy to install and use. Compatible with FPC and Varnish cache extensions.</description>
11
- <notes>+ Versioning of merged CSS and JS files&#xD;
12
- * Improved generation of merged files url</notes>
 
13
  <authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
14
- <date>2015-05-17</date>
15
- <time>16:27:29</time>
16
- <contents><target name="magecommunity"><dir name="Apptrian"><dir name="Minify"><dir name="Block"><file name="About.php" hash="55714f78c451f529f64261efc28ba407"/><file name="Info.php" hash="d967c088301c8e90ada86e8fd8d009bd"/><dir name="Page"><dir name="Html"><file name="Head.php" hash="204827136e6a140524dcd211c8d30ecf"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="de569d80426c7fd01326fa2ba0409c35"/></dir><dir name="Model"><dir name="Config"><file name="Version.php" hash="6d2d900d99752bcbc6be3b8f2a70df44"/></dir><file name="Cron.php" hash="deb94ca0e0d4fc84e7f3b8ec93270e1e"/><file name="Observer.php" hash="628e9692083bebf250b19348d7a2c1d8"/></dir><dir name="etc"><file name="config.xml" hash="59708fa76111c6026bcc2ceae351aa8a"/><file name="system.xml" hash="37e857f3f437ea2e68089b9ac6b59a5d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_Minify.xml" hash="93ef03671067cf44a0b02f0100c8d2d0"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_Minify.csv" hash="1e2631d6b496b0568f1465313d336ef3"/></dir></target><target name="magelib"><dir name="HTTP"><file name="ConditionalGet.php" hash="84d5f4e0b97e37228310a31a4bdc1240"/><file name="Encoder.php" hash="d697f04651d6363d1dd5dd8c2ce94cbd"/></dir><dir name="Minify"><file name="Build.php" hash="99800ab664e1fb0ff46a7133ab13bb1b"/><dir name="CSS"><file name="Compressor.php" hash="6f1d5d8c3f7ac47cabaca9d6ee923206"/><file name="UriRewriter.php" hash="d6c800c1b9b0603c3386f84074bc41a0"/></dir><file name="CSS.php" hash="c585f82e0a6f8af12da2d3337aa7e901"/><file name="CSSmin.php" hash="7e0549e63f49b99aac0f6688bfcf99ef"/><dir name="Cache"><file name="APC.php" hash="f83c096f1ea3eb712bf020371b7d3755"/><file name="File.php" hash="5550b7ad5d3cc20710a0835fdf20e3ec"/><file name="Memcache.php" hash="a572e300270f5cdb535de67eb1d9ce3b"/><file name="WinCache.php" hash="037003b972c8f648880b43b2c912afb7"/><file name="XCache.php" hash="a3239040e672955a8a520eef6e251d68"/><file name="ZendPlatform.php" hash="a20755bc554cfef6733ac64574c4f90e"/></dir><file name="ClosureCompiler.php" hash="0d04a74dae339bd8d2d0465503590819"/><file name="CommentPreserver.php" hash="f9fbae74aea3125d25f375942846d9c0"/><dir name="Controller"><file name="Base.php" hash="756cd27141da15f6bc0a9d34960e0338"/><file name="Files.php" hash="a0bc419aa48d256e19a64596dee53991"/><file name="Groups.php" hash="bf35ccd3d384c40033b978a402eaf917"/><file name="MinApp.php" hash="0910bc4af5280098b8411a8a23aa3e91"/><file name="Page.php" hash="c54a4b19474f9d0e9beb8ccb4e3678b3"/><file name="Version1.php" hash="0e4bce53a0b66c79aa6d15e52cf8ec50"/></dir><file name="DebugDetector.php" hash="d1bee7f6ab4dcf7be5d36dbcd1b81354"/><dir name="HTML"><file name="Helper.php" hash="af89e2e30f70dd935dd86d31649159e6"/></dir><file name="HTML.php" hash="d48eabaae177099a264b5a97379b0abf"/><file name="HTMLComp.php" hash="a2929a26f75e6877fd5f58e6fdc5f2d0"/><file name="HTMLMax.php" hash="63b191db9ce4b878809c33e5cc74323e"/><file name="HTMLMaxComp.php" hash="c6c76d9106d38c3a3fcd7c4ae4ff571a"/><file name="ImportProcessor.php" hash="075c561afa4825021fa44c3cac68ab94"/><dir name="JS"><file name="ClosureCompiler.php" hash="0d6d0017c3b9decdf0e1f647c0b53f17"/></dir><file name="Lines.php" hash="526499d43d682432dac9483da4509179"/><file name="Loader.php" hash="5e84b0e739587d8df742f47953f135d5"/><file name="Logger.php" hash="ee493543ebb47aa06f976f23a0f3d86a"/><file name="Packer.php" hash="e91f63a82c4fbd660c2341163e87dd4b"/><file name="Source.php" hash="f7055f963f00e5ae9f5b0005d5e4a5ec"/><dir name="YUI"><file name="CssCompressor.java" hash="cb15a586f2dcc4fead535bc982e3f91e"/><file name="CssCompressor.php" hash="12d5b4e38488c68bc84cc0efba6eb338"/></dir><file name="YUICompressor.php" hash="3ada081677d0cf118bba1f4b533b97cf"/></dir><dir name="."><file name="CSSmin.php" hash="b88ddd36d0ff681aa8a221467c0c71c1"/><file name="DooDigestAuth.php" hash="9d66abc8cfa37b5f593fc09c734f0269"/><file name="FirePHP.php" hash="f619b5a77fee4b21e4397e98d858fbf4"/><file name="JavaScriptPacker.php" hash="84900da372a375d3b2f117c5abe740a9"/><file name="JSMin.php" hash="63ada69cc753fe4136c67e1d3daabca3"/><file name="JSMinPlus.php" hash="13d47b54dd73ef825e5d86e6cc633e32"/><file name="Minify.php" hash="df50518e69c132b1354eb8ba73a8ed7c"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apptrian_Minify_HTML_CSS_JS</name>
4
+ <version>1.3.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Minify HTML CSS JS including inline CSS/JS and speed up your site. Works with default Magento CSS/JS merger.</summary>
10
  <description>Apptrian Minify HTML CSS JS is a very small and efficient extension. It will minify HTML including inline CSS and JS code. Minification of CSS and JS files is compatible with default Magento CSS and JS file merger. There are no complex setups nor query strings on minified CSS and JS files. Extension is very easy to install and use. Compatible with FPC and Varnish cache extensions.</description>
11
+ <notes>+ Minification of CSS and JS files with a button click in extension configuration&#xD;
12
+ * Eliminated dependency on Mage_Page_Block_Html_Head block (Extension does not rewrite this block nor any other any more)&#xD;
13
+ - Versioning of CSS and JS files</notes>
14
  <authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
15
+ <date>2015-06-15</date>
16
+ <time>21:22:19</time>
17
+ <contents><target name="magecommunity"><dir name="Apptrian"><dir name="Minify"><dir name="Block"><file name="About.php" hash="55714f78c451f529f64261efc28ba407"/><dir name="Adminhtml"><dir name="Button"><file name="Minify.php" hash="4d16be7cfa93b9eba7da21108747e38d"/></dir></dir><file name="Info.php" hash="d967c088301c8e90ada86e8fd8d009bd"/></dir><dir name="Helper"><file name="Data.php" hash="eb14aa3452d47e72829c96f86070be24"/></dir><dir name="Model"><file name="Cron.php" hash="deb94ca0e0d4fc84e7f3b8ec93270e1e"/><file name="Observer.php" hash="628e9692083bebf250b19348d7a2c1d8"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MinifyController.php" hash="3554f1ef8be979bc2170635485d613ba"/></dir></dir><dir name="etc"><file name="config.xml" hash="2d498b4ee11d6c2632935177826e93dc"/><file name="system.xml" hash="ec339915df5322f96eab2ce0bc9a7517"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_Minify.xml" hash="93ef03671067cf44a0b02f0100c8d2d0"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_Minify.csv" hash="ad4e12124cbfb6e028fa69be933992d5"/></dir></target><target name="magelib"><dir name="HTTP"><file name="ConditionalGet.php" hash="84d5f4e0b97e37228310a31a4bdc1240"/><file name="Encoder.php" hash="d697f04651d6363d1dd5dd8c2ce94cbd"/></dir><dir name="Minify"><file name="Build.php" hash="99800ab664e1fb0ff46a7133ab13bb1b"/><dir name="CSS"><file name="Compressor.php" hash="6f1d5d8c3f7ac47cabaca9d6ee923206"/><file name="UriRewriter.php" hash="d6c800c1b9b0603c3386f84074bc41a0"/></dir><file name="CSS.php" hash="c585f82e0a6f8af12da2d3337aa7e901"/><file name="CSSmin.php" hash="7e0549e63f49b99aac0f6688bfcf99ef"/><dir name="Cache"><file name="APC.php" hash="f83c096f1ea3eb712bf020371b7d3755"/><file name="File.php" hash="5550b7ad5d3cc20710a0835fdf20e3ec"/><file name="Memcache.php" hash="a572e300270f5cdb535de67eb1d9ce3b"/><file name="WinCache.php" hash="037003b972c8f648880b43b2c912afb7"/><file name="XCache.php" hash="a3239040e672955a8a520eef6e251d68"/><file name="ZendPlatform.php" hash="a20755bc554cfef6733ac64574c4f90e"/></dir><file name="ClosureCompiler.php" hash="0d04a74dae339bd8d2d0465503590819"/><file name="CommentPreserver.php" hash="f9fbae74aea3125d25f375942846d9c0"/><dir name="Controller"><file name="Base.php" hash="756cd27141da15f6bc0a9d34960e0338"/><file name="Files.php" hash="a0bc419aa48d256e19a64596dee53991"/><file name="Groups.php" hash="bf35ccd3d384c40033b978a402eaf917"/><file name="MinApp.php" hash="0910bc4af5280098b8411a8a23aa3e91"/><file name="Page.php" hash="c54a4b19474f9d0e9beb8ccb4e3678b3"/><file name="Version1.php" hash="0e4bce53a0b66c79aa6d15e52cf8ec50"/></dir><file name="DebugDetector.php" hash="d1bee7f6ab4dcf7be5d36dbcd1b81354"/><dir name="HTML"><file name="Helper.php" hash="af89e2e30f70dd935dd86d31649159e6"/></dir><file name="HTML.php" hash="d48eabaae177099a264b5a97379b0abf"/><file name="HTMLComp.php" hash="a2929a26f75e6877fd5f58e6fdc5f2d0"/><file name="HTMLMax.php" hash="63b191db9ce4b878809c33e5cc74323e"/><file name="HTMLMaxComp.php" hash="c6c76d9106d38c3a3fcd7c4ae4ff571a"/><file name="ImportProcessor.php" hash="075c561afa4825021fa44c3cac68ab94"/><dir name="JS"><file name="ClosureCompiler.php" hash="0d6d0017c3b9decdf0e1f647c0b53f17"/></dir><file name="Lines.php" hash="526499d43d682432dac9483da4509179"/><file name="Loader.php" hash="5e84b0e739587d8df742f47953f135d5"/><file name="Logger.php" hash="ee493543ebb47aa06f976f23a0f3d86a"/><file name="Packer.php" hash="e91f63a82c4fbd660c2341163e87dd4b"/><file name="Source.php" hash="f7055f963f00e5ae9f5b0005d5e4a5ec"/><dir name="YUI"><file name="CssCompressor.java" hash="cb15a586f2dcc4fead535bc982e3f91e"/><file name="CssCompressor.php" hash="12d5b4e38488c68bc84cc0efba6eb338"/></dir><file name="YUICompressor.php" hash="3ada081677d0cf118bba1f4b533b97cf"/></dir><dir name="."><file name="CSSmin.php" hash="b88ddd36d0ff681aa8a221467c0c71c1"/><file name="DooDigestAuth.php" hash="9d66abc8cfa37b5f593fc09c734f0269"/><file name="FirePHP.php" hash="f619b5a77fee4b21e4397e98d858fbf4"/><file name="JavaScriptPacker.php" hash="84900da372a375d3b2f117c5abe740a9"/><file name="JSMin.php" hash="63ada69cc753fe4136c67e1d3daabca3"/><file name="JSMinPlus.php" hash="13d47b54dd73ef825e5d86e6cc633e32"/><file name="Minify.php" hash="df50518e69c132b1354eb8ba73a8ed7c"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>