Version Notes
Skipping condition
Download this release
Release Info
Developer | Denis Derbenyov |
Extension | Radishok_LazyJs |
Version | 0.0.0.5 |
Comparing to | |
See all releases |
Code changes from version 0.0.0.4 to 0.0.0.5
app/code/local/Radishok/LazyJs/Model/Observer.php
CHANGED
@@ -95,24 +95,42 @@ class Radishok_LazyJs_Model_Observer extends Varien_Object{
|
|
95 |
$this->_jsScripts[] = $script;
|
96 |
return '';
|
97 |
}
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
public function afterToHtml($observer) {
|
100 |
if ($observer->getBlock()->getNameInLayout() == 'root' && Mage::getStoreConfig(self::MODULE_ENABLED)){
|
101 |
$request = Mage::app()->getRequest();
|
102 |
$e = $request->getRequestString();
|
103 |
-
$disabled_pages = explode(
|
104 |
$object = $observer->getTransport();
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
-
if(
|
109 |
-
|
110 |
-
} else {
|
111 |
-
$calback = array($this, '_replaceCallback');
|
112 |
}
|
|
|
113 |
$result = preg_replace_callback(
|
114 |
-
array('
|
115 |
-
$
|
116 |
);
|
117 |
$script = $this->_getResultScript();
|
118 |
$object->setHtml(str_replace('</body>', $script.'</body>', $result));
|
95 |
$this->_jsScripts[] = $script;
|
96 |
return '';
|
97 |
}
|
98 |
+
protected function _replaceCallbackMain($matches) {
|
99 |
+
if(strpos($matches[0],'<!--[if')===false && strpos($matches[0],'<![endif]-->')===false){
|
100 |
+
if(Mage::getStoreConfig(self::DEFER_JS)){
|
101 |
+
$callback = array($this, '_replaceCallbackDefer');
|
102 |
+
} else {
|
103 |
+
$callback = array($this, '_replaceCallback');
|
104 |
+
}
|
105 |
+
return call_user_func($callback,$matches);
|
106 |
+
}
|
107 |
+
return $matches[0];
|
108 |
+
}
|
109 |
public function afterToHtml($observer) {
|
110 |
if ($observer->getBlock()->getNameInLayout() == 'root' && Mage::getStoreConfig(self::MODULE_ENABLED)){
|
111 |
$request = Mage::app()->getRequest();
|
112 |
$e = $request->getRequestString();
|
113 |
+
$disabled_pages = explode("\n",Mage::getStoreConfig(self::DISABLED_PAGES));
|
114 |
$object = $observer->getTransport();
|
115 |
+
foreach($disabled_pages as $disabled_page){
|
116 |
+
if(substr($disabled_page,-1)==='*'){
|
117 |
+
$url = substr($disabled_page,0,-1);
|
118 |
+
if(stripos($e, $url)===0){
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
} else {
|
122 |
+
if($e===$disabled_page){
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
}
|
126 |
}
|
127 |
+
if(strripos($object->getHtml(),'</body>')===false){
|
128 |
+
return;
|
|
|
|
|
129 |
}
|
130 |
+
|
131 |
$result = preg_replace_callback(
|
132 |
+
array('#<!--\[if(.*?)\]>(.*?)<!\[endif\]-->|<script(.*?)>(.*?)</script>|<script(.*?)/>#is'),
|
133 |
+
array($this,'_replaceCallbackMain'), $object->getHtml()
|
134 |
);
|
135 |
$script = $this->_getResultScript();
|
136 |
$object->setHtml(str_replace('</body>', $script.'</body>', $result));
|
app/code/local/Radishok/LazyJs/etc/config.xml
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
<config>
|
23 |
<modules>
|
24 |
<Radishok_LazyJs>
|
25 |
-
<version>0.0.0.
|
26 |
</Radishok_LazyJs>
|
27 |
</modules>
|
28 |
<global>
|
@@ -54,7 +54,7 @@
|
|
54 |
<config>
|
55 |
<children>
|
56 |
<radishoklazyjs>
|
57 |
-
<title>Radishok</title>
|
58 |
</radishoklazyjs>
|
59 |
</children>
|
60 |
</config>
|
22 |
<config>
|
23 |
<modules>
|
24 |
<Radishok_LazyJs>
|
25 |
+
<version>0.0.0.5</version>
|
26 |
</Radishok_LazyJs>
|
27 |
</modules>
|
28 |
<global>
|
54 |
<config>
|
55 |
<children>
|
56 |
<radishoklazyjs>
|
57 |
+
<title>Radishok LazyJs</title>
|
58 |
</radishoklazyjs>
|
59 |
</children>
|
60 |
</config>
|
app/code/local/Radishok/LazyJs/etc/system.xml
CHANGED
@@ -45,7 +45,7 @@
|
|
45 |
<show_in_store>1</show_in_store>
|
46 |
<fields>
|
47 |
<active>
|
48 |
-
<label>Module Enabled(version: 0.0.0.
|
49 |
<frontend_type>select</frontend_type>
|
50 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
51 |
<sort_order>10</sort_order>
|
@@ -90,7 +90,7 @@
|
|
90 |
<show_in_default>1</show_in_default>
|
91 |
<show_in_website>1</show_in_website>
|
92 |
<show_in_store>1</show_in_store>
|
93 |
-
<comment><![CDATA[Each request path on new line<br/>Example: <br/>/contacts<br/>/checkout/cart
|
94 |
</disabled_pages>
|
95 |
</fields>
|
96 |
</settings>
|
45 |
<show_in_store>1</show_in_store>
|
46 |
<fields>
|
47 |
<active>
|
48 |
+
<label>Module Enabled(version: 0.0.0.5)</label>
|
49 |
<frontend_type>select</frontend_type>
|
50 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
51 |
<sort_order>10</sort_order>
|
90 |
<show_in_default>1</show_in_default>
|
91 |
<show_in_website>1</show_in_website>
|
92 |
<show_in_store>1</show_in_store>
|
93 |
+
<comment><![CDATA[Each request path on new line<br/>Example: <br/>/contacts<br/>/checkout/cart*<br/>(* character can be used at the end of line)]]></comment>
|
94 |
</disabled_pages>
|
95 |
</fields>
|
96 |
</settings>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Radishok_LazyJs</name>
|
4 |
-
<version>0.0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>This Extension will speed up frontend rendering by placing JavaScript at the bottom of the page </summary>
|
10 |
<description>When you put your JavaScript at the top of the page, the browser will start loading your JS files before the markup, images and text. And since browsers load JavaScript synchronously, nothing else will load while the JavaScript is loading. So there will be a timeframe of a few seconds where the user will see a blank page, while the JavaScript is loading. On the other hand, if you place your JavaScript at the bottom of the page, the user will see the page loading first, and after that the JavaScript will load in the background. So if for example your CSS & HTML takes 5 seconds to load, and your JavaScript takes another 5 seconds, putting our JavaScript on the top of the page will give the user a “perceived” loading time of 10 seconds, and putting it on the bottom will give a “perceived” loading time of 5 seconds.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Denis Derbenyov</name><user>radishok</user><email>ddenisiy@gmail.com</email></author></authors>
|
13 |
-
<date>2014-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="Radishok"><dir name="LazyJs"><dir name="Model"><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Radishok_LazyJs</name>
|
4 |
+
<version>0.0.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>This Extension will speed up frontend rendering by placing JavaScript at the bottom of the page </summary>
|
10 |
<description>When you put your JavaScript at the top of the page, the browser will start loading your JS files before the markup, images and text. And since browsers load JavaScript synchronously, nothing else will load while the JavaScript is loading. So there will be a timeframe of a few seconds where the user will see a blank page, while the JavaScript is loading. On the other hand, if you place your JavaScript at the bottom of the page, the user will see the page loading first, and after that the JavaScript will load in the background. So if for example your CSS & HTML takes 5 seconds to load, and your JavaScript takes another 5 seconds, putting our JavaScript on the top of the page will give the user a “perceived” loading time of 10 seconds, and putting it on the bottom will give a “perceived” loading time of 5 seconds.</description>
|
11 |
+
<notes>Skipping <!--[if ...]> <![endif]--> condition</notes>
|
12 |
<authors><author><name>Denis Derbenyov</name><user>radishok</user><email>ddenisiy@gmail.com</email></author></authors>
|
13 |
+
<date>2014-09-09</date>
|
14 |
+
<time>19:49:19</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Radishok"><dir name="LazyJs"><dir name="Model"><file name="Observer.php" hash="c0719d0cb714c1036fc3a5c739f4164e"/></dir><dir name="etc"><file name="config.xml" hash="35a3fe5b2f42d2c9b27af4939b02150f"/><file name="system.xml" hash="ef7a3a00521f9dbc0637438e591f17c6"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Radishok_LazyJs.xml" hash="594198ce4094a6ac5c47c7d99f36d5d3"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|