• Resolved amjo31

    (@amjo31)


    Suggestion: It would be awesome if there’s a tick option to have the CSS coded minified on the front-end.

    this would make the plugin more lovable by many SEO-picky developers such as myself. Minificaiton is an amazing step!

    • This topic was modified 4 years, 11 months ago by amjo31.
Viewing 1 replies (of 1 total)
  • Thread Starter amjo31

    (@amjo31)

    I do not recommend this in any parallel dimension that may exist, but somehow i was forced to do the following:

    I first created a minimiseCSS() function under functions.php

    function minimiseCSS($css){
        $css = preg_replace('/\/\*((?!\*\/).)*\*\//','',$css); // negative look ahead
        $css = preg_replace('/\s{2,}/',' ',$css);
        $css = preg_replace('/\s*([:;{}])\s*/','$1',$css);
        $css = preg_replace('/;}/','}',$css);
        return $css;
    }

    Then, the part where I don’t feel comfortable with and don’t advise, is going to /wp-content/plugins/wp-add-custom-css/css/custom-css.php and modify line 6:

    // change the below
    echo $custom_css;
    // to the following:
    echo minimiseCss($custom_css);

    I hope this helps other SEO overachievers out there ??

    • This reply was modified 4 years, 9 months ago by amjo31.
Viewing 1 replies (of 1 total)
  • The topic ‘Suggestion: Minify Option’ is closed to new replies.