Fast Velocity Minify - Version 3.2.0

Version Description

[2021.05.06] = * fixed an issue where some files were not being minified * better sourceMappingURL removal during minification

Download this release

Release Info

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

Code changes from version 3.1.9 to 3.2.0

Files changed (5) hide show
  1. fvm.php +1 -1
  2. inc/common.php +14 -18
  3. inc/frontend.php +1 -16
  4. layout/admin-layout-settings.php +2 -2
  5. readme.txt +5 -1
fvm.php CHANGED
@@ -6,7 +6,7 @@ Description: Improve your speed score on GTmetrix, Pingdom Tools and Google Page
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
  Text Domain: fast-velocity-minify
9
- Version: 3.1.9
10
  License: GPL2
11
 
12
  ------------------------------------------------------------------------
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
  Text Domain: fast-velocity-minify
9
+ Version: 3.2.0
10
  License: GPL2
11
 
12
  ------------------------------------------------------------------------
inc/common.php CHANGED
@@ -1146,7 +1146,7 @@ function fvm_simplify_fontface($css_code) {
1146
  function fvm_get_css_from_file($tag) {
1147
 
1148
  # globals
1149
- global $fvm_urls, $fvm_settings;
1150
 
1151
  # variables
1152
  $tvers = get_option('fvm_last_cache_update', '0');
@@ -1173,9 +1173,9 @@ function fvm_get_css_from_file($tag) {
1173
  if(isset($ddl['content'])) {
1174
 
1175
  # minify flag
1176
- $min = false;
1177
- if(isset($fvm_settings['css']['css_enable_min_files']) && $fvm_settings['css']['css_enable_min_files'] == true) {
1178
- $min = true;
1179
  }
1180
 
1181
  # minify
@@ -1208,7 +1208,7 @@ function fvm_get_css_from_file($tag) {
1208
  function fvm_get_js_from_file($tag) {
1209
 
1210
  # globals
1211
- global $fvm_urls, $fvm_settings;
1212
 
1213
  # variables
1214
  $tvers = get_option('fvm_last_cache_update', '0');
@@ -1234,11 +1234,15 @@ function fvm_get_js_from_file($tag) {
1234
  # success
1235
  if(isset($ddl['content'])) {
1236
 
1237
- # minify?
1238
- if(!isset($fvm_settings['js']['min_disable_inline']) || (isset($fvm_settings['js']['min_disable_inline'])&& $fvm_settings['js']['min_disable_inline'] != true)) {
1239
- $js = fvm_maybe_minify_js($ddl['content'], $href, true);
 
1240
  }
1241
 
 
 
 
1242
  # wrap with try catch
1243
  $js = fvm_try_catch_wrap($js, $href);
1244
 
@@ -1707,6 +1711,7 @@ function fvm_maybe_minify_css_file($css, $url, $min) {
1707
 
1708
  # remove sourceMappingURL
1709
  $css = preg_replace('/(\/\/\s*[#]\s*sourceMappingURL\s*[=]\s*)([a-zA-Z0-9-_\.\/]+)(\.map)/ui', '', $css);
 
1710
 
1711
  # fix url paths
1712
  if(!empty($url)) {
@@ -1823,6 +1828,7 @@ function fvm_maybe_minify_js($js, $url, $enable_js_minification) {
1823
 
1824
  # remove sourceMappingURL
1825
  $js = preg_replace('/(\/\/\s*[#]\s*sourceMappingURL\s*[=]\s*)([a-zA-Z0-9-_\.\/]+)(\.map)/ui', '', $js);
 
1826
 
1827
  # minify?
1828
  if($enable_js_minification == true) {
@@ -2026,16 +2032,6 @@ function fvm_get_scheme() {
2026
  return 'http';
2027
  }
2028
 
2029
- # detect http2
2030
- function fvm_has_http2() {
2031
- if(isset($_SERVER['SERVER_PROTOCOL'])) {
2032
- if($_SERVER['SERVER_PROTOCOL'] == 'HTTP/2.0') { return true; }
2033
- }
2034
- return false;
2035
- }
2036
-
2037
-
2038
-
2039
  # get the domain name
2040
  function fvm_get_domain() {
2041
  if (function_exists('site_url')) {
1146
  function fvm_get_css_from_file($tag) {
1147
 
1148
  # globals
1149
+ global $fvm_settings;
1150
 
1151
  # variables
1152
  $tvers = get_option('fvm_last_cache_update', '0');
1173
  if(isset($ddl['content'])) {
1174
 
1175
  # minify flag
1176
+ $min = true;
1177
+ if(isset($fvm_settings['css']['min_disable']) && $fvm_settings['css']['min_disable'] == true) {
1178
+ $min = false;
1179
  }
1180
 
1181
  # minify
1208
  function fvm_get_js_from_file($tag) {
1209
 
1210
  # globals
1211
+ global $fvm_settings;
1212
 
1213
  # variables
1214
  $tvers = get_option('fvm_last_cache_update', '0');
1234
  # success
1235
  if(isset($ddl['content'])) {
1236
 
1237
+ # minify flag
1238
+ $min = true;
1239
+ if(isset($fvm_settings['js']['min_disable']) && $fvm_settings['js']['min_disable'] == true) {
1240
+ $min = false;
1241
  }
1242
 
1243
+ # minify
1244
+ $js = fvm_maybe_minify_js($ddl['content'], $href, $min);
1245
+
1246
  # wrap with try catch
1247
  $js = fvm_try_catch_wrap($js, $href);
1248
 
1711
 
1712
  # remove sourceMappingURL
1713
  $css = preg_replace('/(\/\/\s*[#]\s*sourceMappingURL\s*[=]\s*)([a-zA-Z0-9-_\.\/]+)(\.map)/ui', '', $css);
1714
+ $css = preg_replace('/(\/[*]\s*[#]\s*sourceMappingURL\s*[=]\s*)([a-zA-Z0-9-_\.\/]+)(\.map)\s*[*]\s*[\/]/ui', '', $css);
1715
 
1716
  # fix url paths
1717
  if(!empty($url)) {
1828
 
1829
  # remove sourceMappingURL
1830
  $js = preg_replace('/(\/\/\s*[#]\s*sourceMappingURL\s*[=]\s*)([a-zA-Z0-9-_\.\/]+)(\.map)/ui', '', $js);
1831
+ $js = preg_replace('/(\/[*]\s*[#]\s*sourceMappingURL\s*[=]\s*)([a-zA-Z0-9-_\.\/]+)(\.map)\s*[*]\s*[\/]/ui', '', $js);
1832
 
1833
  # minify?
1834
  if($enable_js_minification == true) {
2032
  return 'http';
2033
  }
2034
 
 
 
 
 
 
 
 
 
 
 
2035
  # get the domain name
2036
  function fvm_get_domain() {
2037
  if (function_exists('site_url')) {
inc/frontend.php CHANGED
@@ -61,7 +61,6 @@ function fvm_process_page($html) {
61
 
62
  # defaults
63
  $tvers = get_option('fvm_last_cache_update', '0');
64
- $httppreloads = array();
65
  $htmlpreloads = array();
66
  $htmlcssheader = array();
67
  $htmljsheader = array();
@@ -312,7 +311,6 @@ function fvm_process_page($html) {
312
 
313
  # http and html preload for render blocking css
314
  if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
315
- $httppreloads[] = '<'.$ind_css_url.'>; rel=preload; as=style';
316
  $htmlpreloads[] = '<link rel="preload" href="'.$ind_css_url.'" as="style" media="'.$tag->media.'" />';
317
  }
318
 
@@ -448,7 +446,6 @@ function fvm_process_page($html) {
448
 
449
  # http and html preload for render blocking css
450
  if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
451
- $httppreloads[] = '<'.$merged_css_url.'>; rel=preload; as=style';
452
  $htmlpreloads[] = '<link rel="preload" href="'.$merged_css_url.'" as="style" media="'.$mediatype.'" />';
453
  }
454
 
@@ -657,7 +654,6 @@ function fvm_process_page($html) {
657
 
658
  # http and html preload for render blocking js
659
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
660
- $httppreloads[] = '<'.$href.'>; rel=preload; as=script';
661
  $htmlpreloads[] = '<link rel="preload" href="'.$href.'" as="script" />';
662
  }
663
 
@@ -714,7 +710,6 @@ function fvm_process_page($html) {
714
 
715
  # http and html preload for render blocking scripts
716
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
717
- $httppreloads[] = '<'.$ind_js_url.'>; rel=preload; as=script';
718
  $htmlpreloads[] = '<link rel="preload" href="'.$ind_js_url.'" as="script" />';
719
  }
720
 
@@ -888,7 +883,6 @@ function fvm_process_page($html) {
888
 
889
  # http and html preload for render blocking scripts
890
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
891
- $httppreloads[] = '<'.$merged_js_url.'>; rel=preload; as=script';
892
  $htmlpreloads[] = '<link rel="preload" href="'.$merged_js_url.'" as="script" />';
893
  }
894
 
@@ -977,22 +971,13 @@ function fvm_process_page($html) {
977
  }
978
 
979
  # preload headers, by importance
980
- if(is_array($htmlpreloads) || is_array($httppreloads)) {
981
 
982
  # deduplicate
983
  $htmlpreloads = array_unique($htmlpreloads);
984
- $httppreloads = array_unique($httppreloads);
985
 
986
  # get values
987
  $pre_html = array_values($htmlpreloads);
988
- $pre_http = array_values($httppreloads);
989
-
990
- # add preload http header
991
- if(count($pre_http) > 0) {
992
- if(!headers_sent() && fvm_get_scheme() && fvm_has_http2()) {
993
- header("Link: " . implode(', ', $pre_http));
994
- }
995
- }
996
 
997
  # add preload html header
998
  if(count($pre_html) > 0) {
61
 
62
  # defaults
63
  $tvers = get_option('fvm_last_cache_update', '0');
 
64
  $htmlpreloads = array();
65
  $htmlcssheader = array();
66
  $htmljsheader = array();
311
 
312
  # http and html preload for render blocking css
313
  if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
 
314
  $htmlpreloads[] = '<link rel="preload" href="'.$ind_css_url.'" as="style" media="'.$tag->media.'" />';
315
  }
316
 
446
 
447
  # http and html preload for render blocking css
448
  if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
 
449
  $htmlpreloads[] = '<link rel="preload" href="'.$merged_css_url.'" as="style" media="'.$mediatype.'" />';
450
  }
451
 
654
 
655
  # http and html preload for render blocking js
656
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
 
657
  $htmlpreloads[] = '<link rel="preload" href="'.$href.'" as="script" />';
658
  }
659
 
710
 
711
  # http and html preload for render blocking scripts
712
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
 
713
  $htmlpreloads[] = '<link rel="preload" href="'.$ind_js_url.'" as="script" />';
714
  }
715
 
883
 
884
  # http and html preload for render blocking scripts
885
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
 
886
  $htmlpreloads[] = '<link rel="preload" href="'.$merged_js_url.'" as="script" />';
887
  }
888
 
971
  }
972
 
973
  # preload headers, by importance
974
+ if(is_array($htmlpreloads)) {
975
 
976
  # deduplicate
977
  $htmlpreloads = array_unique($htmlpreloads);
 
978
 
979
  # get values
980
  $pre_html = array_values($htmlpreloads);
 
 
 
 
 
 
 
 
981
 
982
  # add preload html header
983
  if(count($pre_html) > 0) {
layout/admin-layout-settings.php CHANGED
@@ -122,7 +122,7 @@
122
 
123
  <fieldset>
124
 
125
- <label for="fvm_settings_css_nopreload">
126
  <input name="fvm_settings[css][combine]" type="checkbox" id="fvm_settings_css_combine" value="1" <?php echo fvm_get_settings_checkbox(fvm_get_settings_value($fvm_settings, 'css', 'combine')); ?>>
127
  <?php _e( 'Combine CSS Files', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Deprecated: Will combine all CSS files by mediatype groups in the header (no longer recommended for HTTP/2 servers)', 'fast-velocity-minify' ); ?> ]</span></label>
128
  <br />
@@ -132,7 +132,7 @@
132
  <?php _e( 'Disable CSS Files Minification', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Will disable CSS Files minification for compatibility purposes', 'fast-velocity-minify' ); ?> ]</span></label>
133
  <br />
134
 
135
- <label for="fvm_settings_css_min_disable">
136
  <input name="fvm_settings[css][min_disable_styles]" type="checkbox" id="fvm_settings_css_min_disable_styles" value="1" <?php echo fvm_get_settings_checkbox(fvm_get_settings_value($fvm_settings, 'css', 'min_disable_styles')); ?>>
137
  <?php _e( 'Disable CSS Styles Minification', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Will disable CSS Styles minification for compatibility purposes', 'fast-velocity-minify' ); ?> ]</span></label>
138
  <br />
122
 
123
  <fieldset>
124
 
125
+ <label for="fvm_settings_css_combine">
126
  <input name="fvm_settings[css][combine]" type="checkbox" id="fvm_settings_css_combine" value="1" <?php echo fvm_get_settings_checkbox(fvm_get_settings_value($fvm_settings, 'css', 'combine')); ?>>
127
  <?php _e( 'Combine CSS Files', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Deprecated: Will combine all CSS files by mediatype groups in the header (no longer recommended for HTTP/2 servers)', 'fast-velocity-minify' ); ?> ]</span></label>
128
  <br />
132
  <?php _e( 'Disable CSS Files Minification', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Will disable CSS Files minification for compatibility purposes', 'fast-velocity-minify' ); ?> ]</span></label>
133
  <br />
134
 
135
+ <label for="fvm_settings_css_min_disable_styles">
136
  <input name="fvm_settings[css][min_disable_styles]" type="checkbox" id="fvm_settings_css_min_disable_styles" value="1" <?php echo fvm_get_settings_checkbox(fvm_get_settings_value($fvm_settings, 'css', 'min_disable_styles')); ?>>
137
  <?php _e( 'Disable CSS Styles Minification', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Will disable CSS Styles minification for compatibility purposes', 'fast-velocity-minify' ); ?> ]</span></label>
138
  <br />
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Alignak
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
4
  Requires at least: 4.9
5
  Requires PHP: 5.6
6
- Stable tag: 3.1.9
7
  Tested up to: 5.7.1
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
@@ -48,6 +48,10 @@ You can create a style tag, with an ID equal to "critical-path" ex: `<style id="
48
 
49
  == Changelog ==
50
 
 
 
 
 
51
  = 3.1.9 [2021.05.05] =
52
  * fixed an issue with some base64 encoded fonts and icons becoming invalid
53
  * changed @import CSS rules order according to specification (@import rules need to get processed first when minifying)
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
4
  Requires at least: 4.9
5
  Requires PHP: 5.6
6
+ Stable tag: 3.2.0
7
  Tested up to: 5.7.1
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
48
 
49
  == Changelog ==
50
 
51
+ = 3.2.0 [2021.05.06] =
52
+ * fixed an issue where some files were not being minified
53
+ * better sourceMappingURL removal during minification
54
+
55
  = 3.1.9 [2021.05.05] =
56
  * fixed an issue with some base64 encoded fonts and icons becoming invalid
57
  * changed @import CSS rules order according to specification (@import rules need to get processed first when minifying)