WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Excluding code from minification (11 posts)

  1. indole
    Member
    Posted 3 years ago #

    Is there any way to exclude some HTML from being minified, like through comments?

    The pagination of the main slider on the site looses it's spacing, become bunched up, and moves to the top of the midbar.

    I think it is loosing a div or something and the CSS selector no longer applies.

  2. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    if your HTML is valid, minification will not affect layout. Check the W3C validator: http://validator.w3.org/

    You can add define statements listed in the FAQ usage section if you want to add a conditional statement to prevent a page from being minified.

  3. indole
    Member
    Posted 3 years ago #

    It's valid under transitional and the errors I get while running strict have nothing to do with that part of code.

    It's the homepage, so I might as well not turn on minification : )

    I set up a mirror here if you want to take a look. Email me and I can give you an admin login. It is not configured to do inline JS.

  4. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    Email sent.

  5. indole
    Member
    Posted 3 years ago #

    Any luck? I have had success with other minifiers- maybe you should just include multiple engines on the next release...

  6. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    I'm not able to duplicate the issue. What minify engines would you suggest?

  7. Nic Windley
    Member
    Posted 3 years ago #

    I had a similar problem and found that it was due to some comment that had not been closed correctly.

    I had a piece of JS which started with the following comment;

    <!-- comment

    There was no closed bracket so the HTML minification messed up so it might be worth double checking your code to ensure there are some --> closing all comments.

  8. Nic Windley
    Member
    Posted 3 years ago #

    sorry I meant use // for comments instead

  9. Nic Windley
    Member
    Posted 3 years ago #

    strange for some JS its still killing the code. For example

    This code - works

    <a href='//www.voipfone.co.uk/callmeback.php?code=8e52c3e26f38f90a", 350, 400, "", 20, 20)'><img src="https://www.voipfone.co.uk/images/call-me-back.jpg" width="120" height="60" border="0" align="absmiddle"></a>

    Becomes (when HTML minification is active) - and fails

    <a
    href='JavaScript:openPopWin("http://www.voipfone.co.uk/callmeback.php?code=8e52c3e26f38f90a", 350, 400, "", 20, 20)'><img
    src="https://www.voipfone.co.uk/images/call-me-back.jpg" width="120" height="60" border="0" align="absmiddle">

    Looks like the space between the <a and the href= have been removed and seperated onto different lines

  10. Nic Windley
    Member
    Posted 3 years ago #

    OK, I solved this by avoiding any JS or CSS comment / line removal so when I activated HTML minification (again avoiding comment and line removal) everything worked.

    Excellent!

  11. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    Great.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic