• Resolved devonto

    (@devonto)


    Hi,

    I’m using your plugin with Revolution Slider, which adds lots of HTML5 data parameters to elements.

    AO is adding line breaks after each one, rather than including them inline.

    Can this be changed?

    e.g.

    <div class="tp-caption tp-fade tp-resizeme  start_now_btn"
    data-x="82"
    data-y="525"
    data-speed="300"
    data-start="500"
    data-easing="Power3.easeInOut"
    data-splitin="none"
    data-splitout="none"
    data-elementdelay="0.1"
    data-endelementdelay="0.1"
    data-endspeed="300"
    style="z-index: 7; max-width: auto; max-height: auto; white-space: nowrap;"><p class="link-b"><a href="/">Learn more <i class="fa fa-chevron-right"></i></a></p></div><div class="tp-caption tp-fade"
    data-x="637"
    data-y="192"
    data-speed="300"
    data-start="500"
    data-easing="Power3.easeInOut"
    data-elementdelay="0.1"
    data-endelementdelay="0.1"
    data-endspeed="300"
    style="z-index: 8;">

    https://www.ads-software.com/plugins/autoptimize/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frank Goossens

    (@futtta)

    hiya devonto;
    The HTML minimizer AO uses does not seem to support removing line-breaks between attributes of a tag, so there’s no solution for this (yet). That being said, if you’re into coding yourself you could use the autoptimize_html_after_minify filter to remove the linebrakes from the minified HTML yourself. If you have a working function I’ll be happy to review & consider inclusion in AO proper! ??

    Kind regards,
    frank

    Plugin Author Frank Goossens

    (@futtta)

    someone asked a similar question and while on the train home I whipped up this little code-snippet;

    add_filter('autoptimize_html_after_minify','remove_data_newlines',10,1);
    function remove_data_newlines($htmlIn) {
    	$htmlOut=preg_replace('/\ndata-/', ' data-', $htmlIn);
    	return $htmlOut;
    }

    put this in your (child-)theme’s functions.php and the newlines should be gone (the regex can still be vastly improved upon to only remove newlines if “data-” is part of an attribute name, but I’ll leave that to someone else ?? )

    frank

    Thread Starter devonto

    (@devonto)

    Great, thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘HTML5 data-X parameters on new lines, should be in-lined?’ is closed to new replies.