WordPress.org

Ready to get started?Download WordPress

Forums

WP Minify
Ill-conceived line-wrapping of HTML for "human readability" remains (5 posts)

  1. belg4mit
    Member
    Posted 2 years ago #

    Around version 1, when the HTML minification was added, the following code was put into min/lib/Minify/HTML.php around line 139

    // use newlines before 1st attribute in open tags (to limit line lengths
    )
            $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);

    These newlines serve no purpose other than to match one person's aesthetics about the way HTML should look. On the other hand they increase the size of the page (despite being an uncontrollable "feature" in a module of code meant to reduce file size) AND more importantly, they very often break (inline) JavaScript.

    Earlier report here: http://webcache.googleusercontent.com/search?q=cache:20_of60FEyAJ:omninoggin.com/forum/index.php%3Ftopic%3D401.0+min/lib/Minify/HTML.php+site:omninoggin.com&cd=4&hl=en&ct=clnk&gl=us&lr=lang_fr|lang_en&client=firefox-a

    Other than this misfeature, the module is great and does in fact work with 3.2.1... at least, the 1.0.4 version does, which I am sticking with until this is fixed, because I do not wish to have to repatch the plug-in after every upgrade but do wish to benefit from the rest of the HTML minification.

    http://wordpress.org/extend/plugins/wp-minify/

  2. MickeyRoush
    Member
    Posted 2 years ago #

    I'm glad I'm not the only one whose still using version 1.0.4

  3. bradvin
    Member
    Posted 2 years ago #

    To the author of this plugin:

    regarding line 138 in HTML.php (version 1.1.8 of wpminify)

    code:

    // use newlines before 1st attribute in open tags (to limit line lengths)
    $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);

    Please can this be a feature that can be turned off by default in the settings page, or even removed entirely?

    I really do not know why anyone would want this feature, as it adds more characters to the HTML output.

    The reason I am wanting it removed is that enabling HTML minification breaks other plugin's javascript, as javascript strings with line breaks will not work. More info : http://www.willmaster.com/blog/javascript/strings-line-breaks.php

    So if the javascript contains string literals with HTML code, then newline characters are being added. Example:

    This valid javascript:

    var html = 'Link';

    becomes

    var html = '<a
    href="#">Link';
    

    and is now not valid javascript.

    This is a major problem for plugin developers, because there is no way for us to get around this.

  4. chadrew
    Member
    Posted 1 year ago #

    Is it safe to just comment out the line in question?

  5. Kimberly
    Member
    Posted 1 year ago #

    @chadrew: Yes!

    And consider it a mandatory thing to do when you get this plugin. There are other bugs we've discovered that may affect you which we addressed and fixed so feel free to read other comments for them if interested. But the one fix we all agree everyone should do is the one outlined in here. The other fixes may not be relevant to your site.

    And btw, this is by far the stupidest feature (adding new lines to prevent html from getting too long) i've ever seen.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags