Changeset 1873420
- Timestamp:
- 05/13/2018 05:19:53 AM (8 years ago)
- Location:
- html-minifier/trunk
- Files:
-
- 3 edited
-
html-minifier.php (modified) (2 diffs)
-
inc/src/HTMLMinifier.php (modified) (9 diffs)
-
readme.md (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
html-minifier/trunk/html-minifier.php
r1873072 r1873420 7 7 Plugin URI: http://www.terresquall.com/web/html-minifier/ 8 8 Description: Provides a variety of optimisation options (e.g. minification, caching, code reorganisation) for your site's source code to help meet today's web performance standards. 9 Version: 2.2. 110 Dated: 1 2/05/20189 Version: 2.2.2 10 Dated: 13/05/2018 11 11 Author: Terresquall 12 12 Author URI: http://www.terresquall.com/ … … 29 29 require_once HTML_MINIFIER__PLUGIN_DIR . 'inc/HTMLMinifier.manager.php'; 30 30 31 define('HTML_MINIFIER_PLUGIN_VERSION', '2.2. 1');32 define('HTML_MINIFIER_PLUGIN_VERSION_DATE', '1 2May 2018');31 define('HTML_MINIFIER_PLUGIN_VERSION', '2.2.2'); 32 define('HTML_MINIFIER_PLUGIN_VERSION_DATE', '13 May 2018'); 33 33 34 34 add_action('init',array('HTMLMinifier_Manager','init')); -
html-minifier/trunk/inc/src/HTMLMinifier.php
r1870809 r1873420 9 9 @author Terence Pek <terence@terresquall.com> 10 10 @website www.terresquall.com 11 @version 3.0.8 12 @dated 30/04/2018 13 @notes - Added support for 'compression_ignored_tags' and deprecated 'compression_ignore_script_tags'. 11 @version 3.0.9 12 @dated 13/05/2018 13 @notes - Fixed a bug causing <style scoped> tags to not have their comments cleaned. 14 - Fixed a bug with <style> types nested in IE conditional tags causing a fatal error. 15 - <script> tags that have an 'id' attribute are no longer merged with other scripts. 16 - Non-Javascript <script> tags are no longer moved, and Javascript comments in them are no longer removed. 17 - Added support for 'compression_ignored_tags' and deprecated 'compression_ignore_script_tags'. 14 18 - Double slashes (//) in Javascript regex blocks no longer get identified as comments. 15 19 - Added support for minifying JS / CSS files. … … 28 32 public static $CacheExpiry = 86400; // Time in seconds. 86400 is 1 day. 29 33 30 const VERSION = '3.0. 8';34 const VERSION = '3.0.9'; 31 35 const SIGNATURE = 'Original size: %d bytes, minified: %d bytes. HTMLMinifier: www.terresquall.com/web/html-minifier.'; 32 36 const CACHE_SIG = 'Server cached on %s.'; … … 82 86 'shift_script_tags_to_bottom' => array('combine_javascript_in_script_tags' => true, 'ignore_async_and_defer_tags' => true), 83 87 //'compression_ignore_script_tags' => false, //LEGACY ATTRIBUTE 84 'compression_ignored_tags' => array('textarea','pre'),85 88 'compression_mode' => 'all_whitespace' 86 89 ) … … 410 413 if($options['shift_style_tags_to_head']) { 411 414 412 // Ignore <style> tags that have the scoped attribute .415 // Ignore <style> tags that have the scoped attribute (process them for comments first). 413 416 $style = self::get_tag_attributes($css[1][$k]); 414 if(isset($style['scoped'])) continue; 417 if(isset($style['scoped'])) { 418 if($options['clean_css_comments']) $source = self::replace($m,$css[0][$k],$source); 419 continue; 420 } 415 421 416 422 // For use below. … … 465 471 466 472 // Find style tags in the comment and remove CSS comments within. 467 if($options[' remove_css_comments']) {473 if($options['clean_css_comments']) { 468 474 $styles = self::get_tags('style',$comments[$comment_tag]); 469 foreach($styles as $key => $str) {475 foreach($styles[0] as $key => $str) { 470 476 if(!preg_match('@^<style@i',$str)) continue; 471 477 $styles[2][$key] = self::remove_comments($styles[2][$key],'css',$ignore_cdata_comments); … … 605 611 foreach($scripts[0] as $k => $s) { 606 612 607 if(preg_match('@^<noscript@i',$scripts[1][$k])) continue; // Ignore everything inside a <noscript> tag.613 if(preg_match('@^<noscript@i',$scripts[1][$k])) continue; // Causes all tags embedded in <noscript> to be ignored. 608 614 609 615 if(preg_match('@!--@',$s)) { … … 623 629 624 630 $attrb = self::get_tag_attributes($str); 631 632 // If this tag is not Javascript, let's ignore it and move on. 633 if(isset($attrb['type']) && !preg_match('@(text|application)/(x-)?javascript@i',$attrb['type'])) 634 continue; 625 635 626 636 // Compress script if we set script compression to true. … … 664 674 $attrb = self::get_tag_attributes($scripts[1][$k]); 665 675 676 // If this tag is not Javascript, let's ignore it and move on. 677 if(isset($attrb['type']) && !preg_match('@(text|application)/(x-)?javascript@i',$attrb['type'])) 678 continue; 679 666 680 // Wrap scripts in conditionals with respective conditionals. 667 681 $is_wrapped = self::_is_in_wrapped_conditionals($scripts[0][$k],$wrapped_conditionals,$source); … … 683 697 684 698 // Figure out if this is a piece of script we should combine or just append at the end. 685 if(! $is_wrapped && trim($scripts[2][$k]) && $combine_javascript) {699 if(!isset($attrb['id']) && !$is_wrapped && trim($scripts[2][$k]) && $combine_javascript) { 686 700 687 if(!$attrb || (count($attrb) === 1 && (isset($attrb['type']) && $attrb['type'] == 'text/javascript'))) { 688 // We are moving the script to the end of the page. 689 $source = self::replace($s,'',$source); 690 $script_combine .= $scripts[2][$k] . PHP_EOL; 691 continue; 692 } 701 // We are moving the script to the end of the page. 702 $source = self::replace($s,'',$source); 703 $script_combine .= $scripts[2][$k] . PHP_EOL; 704 continue; 693 705 694 706 } -
html-minifier/trunk/readme.md
r1873072 r1873420 5 5 Requires at least: 3.6.4 6 6 Tested up to: 4.9.5 7 Stable tag: 2.2. 17 Stable tag: 2.2.2 8 8 Requires PHP: 5.4 and above 9 9 License: GPLv2 or later … … 24 24 25 25 == Changelog == 26 27 = 2.2.2 = 28 *Release Date - 13 May 2018* 29 30 * Fixed a bug causing <style scoped> tags to not have their comments cleaned. 31 * Fixed a bug with <style> types nested in IE conditional tags causing a fatal error. 32 * <script> tags that have an 'id' attribute are no longer merged with other scripts. 33 * Non-Javascript <script> tags are no longer moved if you choose to move Javascript to the bottom of the page, and comments in these non-Javascript tags are no longer removed. 34 * Improved detection algorithm for identifying what are Javascript blocks and what are not. 26 35 27 36 = 2.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.