• Resolved morespinach

    (@morespinach)


    Love this all-encompassing plugin. We have an issue with HTML minification. In our templates, when we use a few spaces inside attributes, which we do for legible reading in the source code, we’d like it to be replaced by single spaces in the minified version in production. This is how various tools such as Gulp etc work. But we’re finding that html minify from Clearfy leaves some specific things alone and does *not* minify them. Why?

    For example, take a look at the page source of the attached URL:
    https://geislingen.estdocs.com/stories/heading-to-the-free-world/

    There’s no reason the line breaks here should be line breaks at all. They can easily become one space, which would make them a single long line of all HTML.

    What am I missing? Welcome any pointers. Thanks!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    Can you turn off the minification so I can see what the code looks like in the source?

    Thread Starter morespinach

    (@morespinach)

    Done now. Please try?

    Thread Starter morespinach

    (@morespinach)

    In case it helps, sharing pastebin code..

    Without minify:
    https://pastebin.com/tGjhj8T5

    After minify:
    https://pastebin.com/rJYj88QY

    The Minify component in Clearfy does not cut line breaks inside html tags, as this may break the HTML markup.
    You can remove line breaks or leave as is.

    Thread Starter morespinach

    (@morespinach)

    Why would it break HTML? There’s nothing in the spec that says removing a newline from a tag like this is invalid–

    
        <a     href='something.com/somepage/somefinalurl'     
    
         target='_blank' 
         data-somecustomvariable='some other value'
        > 
    

    This could quite safely be made:

    
        <a href='something.com/somepage/somefinalurl' target='_blank' 
     data-somecustomvariable='some other value' > 
    

    In other words: replace all individual occurrences of “white space” (a space or more, tabs, newline characters) with one space each. This is perfectly valid HTML.

    Happy to be corrected. If clearfy cannot do this I might have to look for another plugin to do just this.

    • This reply was modified 6 years, 11 months ago by morespinach.
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘About HTML Minify’ is closed to new replies.