Fast Velocity Minify - Version 2.7.0

Version Description

[2019.07.23] = * some score fixes when deferring to pagespeed is enabled

Download this release

Release Info

Developer Alignak
Plugin Icon 128x128 Fast Velocity Minify
Version 2.7.0
Comparing to
See all releases

Code changes from version 2.6.9 to 2.7.0

Files changed (2) hide show
  1. fvm.php +29 -16
  2. readme.txt +4 -1
fvm.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://fastvelocity.com
5
  Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
- Version: 2.6.9
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
@@ -160,7 +160,20 @@ if($fvm_gfonts_method != false) {
160
 
161
 
162
  # default ua list
163
- $fvmualist = array('x11.*fox\/54', 'oid\s4.*xus.*ome\/62', 'x11.*ome\/62', 'oobot', 'ighth', 'tmetr', 'eadles', 'ingdo');
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
 
166
  # add admin page and rewrite defaults
@@ -294,7 +307,7 @@ function fastvelocity_min_files_callback() {
294
 
295
  # default
296
  $size = fastvelocity_get_cachestats();
297
- $return = array('js' => array(), 'css' => array(), 'stamp' => $_POST['stamp'], 'cachesize'=> $size);
298
 
299
  # inspect directory with opendir, since glob might not be available in some systems
300
  clearstatcache();
@@ -1230,7 +1243,7 @@ if (isset($wp_scripts->registered[$handle]->extra["group"]) || isset($wp_scripts
1230
  foreach($fvm_min_excludejslist as $l) {
1231
  if (stripos($hurl, $l) !== false) {
1232
  # print code if there are no linebreaks, or return
1233
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
1234
  echo "loadAsync('$hurl', null);";
1235
  echo '}</script>';
1236
  $skipjs = true;
@@ -1437,7 +1450,7 @@ foreach( $scripts->to_do as $handle ) :
1437
  foreach($fvm_min_excludejslist as $l) {
1438
  if (stripos($hurl, $l) !== false) {
1439
  # print code if there are no linebreaks, or return
1440
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
1441
  echo "loadAsync('$hurl', null);";
1442
  echo '}</script>';
1443
  $skipjs = true;
@@ -1653,7 +1666,7 @@ if (stripos($tag, 'defer') === false && stripos($tag, 'async') === false) {
1653
  $jsdeferpsionly = '<script type="text/javascript">if(navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){document.write('.fastvelocity_escape_url_js($jsdeferpsi).');}else{document.write('.fastvelocity_escape_url_js($tag).');}</script>';
1654
 
1655
  # hide tag from PSI
1656
- $jsdeferhidepsi = '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){document.write('.fastvelocity_escape_url_js($tag).');}</script>';
1657
 
1658
  # must return by this order...
1659
 
@@ -1752,7 +1765,7 @@ foreach( $styles->to_do as $handle):
1752
  # Exclude specific CSS files from PSI?
1753
  if($fvm_min_excludecsslist != false && is_array($fvm_min_excludecsslist) && fastvelocity_min_in_arrayi($hurl, $fvm_min_excludecsslist)) {
1754
  $cssguid = 'fvm'.hash('adler32', $hurl);
1755
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
1756
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
1757
  echo '}</script>';
1758
  $done = array_merge($done, array($handle)); continue;
@@ -1769,7 +1782,7 @@ foreach( $styles->to_do as $handle):
1769
  # font awesome processing, async and exclude from PSI
1770
  if($fvm_fawesome_method == 3 && stripos($hurl, 'font-awesome') !== false) {
1771
  $cssguid = 'fvm'.hash('adler32', $hurl);
1772
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
1773
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
1774
  echo '}</script>';
1775
  $done = array_merge($done, array($handle)); continue;
@@ -1817,7 +1830,7 @@ if(!$skip_google_fonts && count($google_fonts) > 0 || ($force_inline_googlefonts
1817
 
1818
  # make a stylesheet, hide from PSI
1819
  $cssguid = 'fvm'.hash('adler32', $gfurl);
1820
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
1821
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$gfurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
1822
  echo '}</script>';
1823
 
@@ -2164,7 +2177,7 @@ if(!$skip_google_fonts && count($google_fonts) > 0 || ($force_inline_googlefonts
2164
 
2165
  # make a stylesheet, hide from PSI
2166
  $cssguid = 'fvm'.hash('adler32', $gfurl);
2167
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2168
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$gfurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2169
  echo '}</script>';
2170
 
@@ -2255,7 +2268,7 @@ foreach( $styles->to_do as $handle ) :
2255
  # Exclude specific CSS files from PSI?
2256
  if($fvm_min_excludecsslist != false && is_array($fvm_min_excludecsslist) && fastvelocity_min_in_arrayi($hurl, $fvm_min_excludecsslist)) {
2257
  $cssguid = 'fvm'.hash('adler32', $hurl);
2258
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2259
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2260
  echo '}</script>';
2261
  $done = array_merge($done, array($handle)); continue;
@@ -2272,7 +2285,7 @@ foreach( $styles->to_do as $handle ) :
2272
  # font awesome processing, async and exclude from PSI
2273
  if($fvm_fawesome_method == 3 && stripos($hurl, 'font-awesome') !== false) {
2274
  $cssguid = 'fvm'.hash('adler32', $hurl);
2275
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2276
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2277
  echo '}</script>';
2278
  $done = array_merge($done, array($handle)); continue;
@@ -2612,7 +2625,7 @@ function fastvelocity_optimizecss($html, $handle, $href, $media){
2612
  # Exclude specific CSS files from PSI?
2613
  if($fvm_min_excludecsslist != false && is_array($fvm_min_excludecsslist) && fastvelocity_min_in_arrayi($href, $fvm_min_excludecsslist)) {
2614
  $cssguid = 'fvm'.hash('adler32', $href);
2615
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2616
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$href.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$media.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2617
  echo '}</script>';
2618
  return false;
@@ -2637,7 +2650,7 @@ function fastvelocity_optimizecss($html, $handle, $href, $media){
2637
  # hide google fonts from PSI
2638
  if($css_hide_googlefonts == true) {
2639
  $cssguid = 'fvm'.hash('adler32', $href);
2640
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2641
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$href.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2642
  echo '}</script>';
2643
  return false;
@@ -2663,7 +2676,7 @@ function fastvelocity_optimizecss($html, $handle, $href, $media){
2663
  # font awesome processing, async and exclude from PSI
2664
  if($fvm_fawesome_method == 3 && stripos($href, 'font-awesome') !== false) {
2665
  $cssguid = 'fvm'.hash('adler32', $href);
2666
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2667
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$href.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$media.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2668
  echo '}</script>';
2669
  return false;
@@ -2818,7 +2831,7 @@ function fastvelocity_add_google_fonts_merged() {
2818
 
2819
  # make a stylesheet, hide from PSI
2820
  $cssguid = 'fvm'.hash('adler32', $gfurl);
2821
- echo '<script type="text/javascript">if(!navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){';
2822
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$gfurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2823
  echo '}</script>';
2824
 
5
  Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
+ Version: 2.7.0
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
160
 
161
 
162
  # default ua list
163
+ $fvmualist = array('x11.*fox\/54', 'oid\s4.*xus.*ome\/62', 'oobot', 'ighth', 'tmetr', 'eadles', 'ingdo');
164
+
165
+ # header and footer markers
166
+ add_action('wp_head','fastvelocity_add_fvmuag', -PHP_INT_MAX);
167
+ function fastvelocity_add_fvmuag() {
168
+ global $fvmualist;
169
+ echo '<script>'.fastvelocity_get_fvmuag($fvmualist).'</script>';
170
+ }
171
+
172
+ # generate fvmuag js function
173
+ function fastvelocity_get_fvmuag($fvmualist) {
174
+ return 'function fvmuag(){if(navigator.userAgent.match(/'.implode('|', $fvmualist).'/i))return!1;if(navigator.userAgent.match(/x11.*ome\/75\.0\.3770\.100/i)){var e=screen.width,t=screen.height;if("number"==typeof e&&"number"==typeof t&&862==t&&1367==e)return!1}return!0}';
175
+ }
176
+
177
 
178
 
179
  # add admin page and rewrite defaults
307
 
308
  # default
309
  $size = fastvelocity_get_cachestats();
310
+ $return = array('js' => array(), 'css' => array(), 'cachesize'=> $size);
311
 
312
  # inspect directory with opendir, since glob might not be available in some systems
313
  clearstatcache();
1243
  foreach($fvm_min_excludejslist as $l) {
1244
  if (stripos($hurl, $l) !== false) {
1245
  # print code if there are no linebreaks, or return
1246
+ echo '<script type="text/javascript">if(fvmuag()){';
1247
  echo "loadAsync('$hurl', null);";
1248
  echo '}</script>';
1249
  $skipjs = true;
1450
  foreach($fvm_min_excludejslist as $l) {
1451
  if (stripos($hurl, $l) !== false) {
1452
  # print code if there are no linebreaks, or return
1453
+ echo '<script type="text/javascript">if(fvmuag()){';
1454
  echo "loadAsync('$hurl', null);";
1455
  echo '}</script>';
1456
  $skipjs = true;
1666
  $jsdeferpsionly = '<script type="text/javascript">if(navigator.userAgent.match(/'.implode('|', $fvmualist).'/i)){document.write('.fastvelocity_escape_url_js($jsdeferpsi).');}else{document.write('.fastvelocity_escape_url_js($tag).');}</script>';
1667
 
1668
  # hide tag from PSI
1669
+ $jsdeferhidepsi = '<script type="text/javascript">if(fvmuag()){document.write('.fastvelocity_escape_url_js($tag).');}</script>';
1670
 
1671
  # must return by this order...
1672
 
1765
  # Exclude specific CSS files from PSI?
1766
  if($fvm_min_excludecsslist != false && is_array($fvm_min_excludecsslist) && fastvelocity_min_in_arrayi($hurl, $fvm_min_excludecsslist)) {
1767
  $cssguid = 'fvm'.hash('adler32', $hurl);
1768
+ echo '<script type="text/javascript">if(fvmuag()){';
1769
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
1770
  echo '}</script>';
1771
  $done = array_merge($done, array($handle)); continue;
1782
  # font awesome processing, async and exclude from PSI
1783
  if($fvm_fawesome_method == 3 && stripos($hurl, 'font-awesome') !== false) {
1784
  $cssguid = 'fvm'.hash('adler32', $hurl);
1785
+ echo '<script type="text/javascript">if(fvmuag()){';
1786
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
1787
  echo '}</script>';
1788
  $done = array_merge($done, array($handle)); continue;
1830
 
1831
  # make a stylesheet, hide from PSI
1832
  $cssguid = 'fvm'.hash('adler32', $gfurl);
1833
+ echo '<script type="text/javascript">if(fvmuag()){';
1834
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$gfurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
1835
  echo '}</script>';
1836
 
2177
 
2178
  # make a stylesheet, hide from PSI
2179
  $cssguid = 'fvm'.hash('adler32', $gfurl);
2180
+ echo '<script type="text/javascript">if(fvmuag()){';
2181
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$gfurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2182
  echo '}</script>';
2183
 
2268
  # Exclude specific CSS files from PSI?
2269
  if($fvm_min_excludecsslist != false && is_array($fvm_min_excludecsslist) && fastvelocity_min_in_arrayi($hurl, $fvm_min_excludecsslist)) {
2270
  $cssguid = 'fvm'.hash('adler32', $hurl);
2271
+ echo '<script type="text/javascript">if(fvmuag()){';
2272
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2273
  echo '}</script>';
2274
  $done = array_merge($done, array($handle)); continue;
2285
  # font awesome processing, async and exclude from PSI
2286
  if($fvm_fawesome_method == 3 && stripos($hurl, 'font-awesome') !== false) {
2287
  $cssguid = 'fvm'.hash('adler32', $hurl);
2288
+ echo '<script type="text/javascript">if(fvmuag()){';
2289
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$hurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$mediatype.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2290
  echo '}</script>';
2291
  $done = array_merge($done, array($handle)); continue;
2625
  # Exclude specific CSS files from PSI?
2626
  if($fvm_min_excludecsslist != false && is_array($fvm_min_excludecsslist) && fastvelocity_min_in_arrayi($href, $fvm_min_excludecsslist)) {
2627
  $cssguid = 'fvm'.hash('adler32', $href);
2628
+ echo '<script type="text/javascript">if(fvmuag()){';
2629
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$href.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$media.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2630
  echo '}</script>';
2631
  return false;
2650
  # hide google fonts from PSI
2651
  if($css_hide_googlefonts == true) {
2652
  $cssguid = 'fvm'.hash('adler32', $href);
2653
+ echo '<script type="text/javascript">if(fvmuag()){';
2654
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$href.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2655
  echo '}</script>';
2656
  return false;
2676
  # font awesome processing, async and exclude from PSI
2677
  if($fvm_fawesome_method == 3 && stripos($href, 'font-awesome') !== false) {
2678
  $cssguid = 'fvm'.hash('adler32', $href);
2679
+ echo '<script type="text/javascript">if(fvmuag()){';
2680
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$href.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="'.$media.'"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2681
  echo '}</script>';
2682
  return false;
2831
 
2832
  # make a stylesheet, hide from PSI
2833
  $cssguid = 'fvm'.hash('adler32', $gfurl);
2834
+ echo '<script type="text/javascript">if(fvmuag()){';
2835
  echo 'var '.$cssguid.'=document.createElement("link");'.$cssguid.'.rel="stylesheet",'.$cssguid.'.type="text/css",'.$cssguid.'.media="async",'.$cssguid.'.href="'.$gfurl.'",'.$cssguid.'.onload=function(){'.$cssguid.'.media="all"},document.getElementsByTagName("head")[0].appendChild('.$cssguid.');';
2836
  echo '}</script>';
2837
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Alignak
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
4
  Requires at least: 4.5
5
  Requires PHP: 5.5
6
- Stable tag: 2.6.9
7
  Tested up to: 5.2.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -198,6 +198,9 @@ Please backup your site before updating. Version 3.0 will have a major code rewr
198
 
199
  == Changelog ==
200
 
 
 
 
201
  = 2.6.9 [2019.07.15] =
202
  * custom cache path permissions fix (thanks to @fariazz)
203
 
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
4
  Requires at least: 4.5
5
  Requires PHP: 5.5
6
+ Stable tag: 2.7.0
7
  Tested up to: 5.2.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
198
 
199
  == Changelog ==
200
 
201
+ = 2.7.0 [2019.07.23] =
202
+ * some score fixes when deferring to pagespeed is enabled
203
+
204
  = 2.6.9 [2019.07.15] =
205
  * custom cache path permissions fix (thanks to @fariazz)
206