Plugin Directory

Changeset 1873420


Ignore:
Timestamp:
05/13/2018 05:19:53 AM (8 years ago)
Author:
terresquall
Message:

Bug fixes for v2.2.2 commit.

Location:
html-minifier/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • html-minifier/trunk/html-minifier.php

    r1873072 r1873420  
    77Plugin URI: http://www.terresquall.com/web/html-minifier/
    88Description: 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.1
    10 Dated: 12/05/2018
     9Version: 2.2.2
     10Dated: 13/05/2018
    1111Author: Terresquall
    1212Author URI: http://www.terresquall.com/
     
    2929require_once HTML_MINIFIER__PLUGIN_DIR . 'inc/HTMLMinifier.manager.php';
    3030
    31 define('HTML_MINIFIER_PLUGIN_VERSION', '2.2.1');
    32 define('HTML_MINIFIER_PLUGIN_VERSION_DATE', '12 May 2018');
     31define('HTML_MINIFIER_PLUGIN_VERSION', '2.2.2');
     32define('HTML_MINIFIER_PLUGIN_VERSION_DATE', '13 May 2018');
    3333
    3434add_action('init',array('HTMLMinifier_Manager','init'));
  • html-minifier/trunk/inc/src/HTMLMinifier.php

    r1870809 r1873420  
    99@author     Terence Pek <terence@terresquall.com>
    1010@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'.
    1418            - Double slashes (//) in Javascript regex blocks no longer get identified as comments.
    1519            - Added support for minifying JS / CSS files.
     
    2832    public static $CacheExpiry = 86400; // Time in seconds. 86400 is 1 day.
    2933   
    30     const VERSION = '3.0.8';
     34    const VERSION = '3.0.9';
    3135    const SIGNATURE = 'Original size: %d bytes, minified: %d bytes. HTMLMinifier: www.terresquall.com/web/html-minifier.';
    3236    const CACHE_SIG = 'Server cached on %s.';
     
    8286            'shift_script_tags_to_bottom' => array('combine_javascript_in_script_tags' => true, 'ignore_async_and_defer_tags' => true),
    8387            //'compression_ignore_script_tags' => false, //LEGACY ATTRIBUTE
    84             'compression_ignored_tags' => array('textarea','pre'),
    8588            'compression_mode' => 'all_whitespace'
    8689        )
     
    410413                if($options['shift_style_tags_to_head']) {
    411414                   
    412                     // Ignore <style> tags that have the scoped attribute.
     415                    // Ignore <style> tags that have the scoped attribute (process them for comments first).
    413416                    $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                    }
    415421                   
    416422                    // For use below.
     
    465471                   
    466472                    // Find style tags in the comment and remove CSS comments within.
    467                     if($options['remove_css_comments']) {
     473                    if($options['clean_css_comments']) {
    468474                        $styles = self::get_tags('style',$comments[$comment_tag]);
    469                         foreach($styles as $key => $str) {
     475                        foreach($styles[0] as $key => $str) {
    470476                            if(!preg_match('@^<style@i',$str)) continue;
    471477                            $styles[2][$key] = self::remove_comments($styles[2][$key],'css',$ignore_cdata_comments);
     
    605611        foreach($scripts[0] as $k => $s) {
    606612           
    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.
    608614           
    609615            if(preg_match('@!--@',$s)) {
     
    623629                           
    624630                            $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;
    625635                           
    626636                            // Compress script if we set script compression to true.
     
    664674                $attrb = self::get_tag_attributes($scripts[1][$k]);
    665675               
     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               
    666680                // Wrap scripts in conditionals with respective conditionals.
    667681                $is_wrapped = self::_is_in_wrapped_conditionals($scripts[0][$k],$wrapped_conditionals,$source);
     
    683697                   
    684698                    // 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) {
    686700                       
    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;
    693705                       
    694706                    }
  • html-minifier/trunk/readme.md

    r1873072 r1873420  
    55Requires at least: 3.6.4
    66Tested up to: 4.9.5
    7 Stable tag: 2.2.1
     7Stable tag: 2.2.2
    88Requires PHP: 5.4 and above
    99License: GPLv2 or later
     
    2424
    2525== Changelog ==
     26
     27= 2.2.2 =
     28*Release Date - 13 May 2018*
     29
     30* Fixed a bug causing &lt;style scoped&gt; tags to not have their comments cleaned.
     31* Fixed a bug with &lt;style&gt; types nested in IE conditional tags causing a fatal error.
     32* &lt;script&gt; tags that have an 'id' attribute are no longer merged with other scripts.
     33* Non-Javascript &lt;script&gt; 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.
    2635
    2736= 2.2.1 =
Note: See TracChangeset for help on using the changeset viewer.