Support » Plugin: Fast Velocity Minify » Idea for an additional optimization (wp-custom-css)

  • Resolved urikanonov



    I’ve been trying to optimize my site’s content and I realized that the custom wordpress CSS isn’t being minified.
    So the workaround I figured is the following code. Hope there aren’t any pitfalls I don’t see there but if not, I think it’d be a good idea to add the plugin 🙂

    function minify_custom_css($css, $stylesheet)
    return fastvelocity_min_minify_css_string($css);
    add_filter(‘wp_get_custom_css’, ‘minify_custom_css’, 100, 2);


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Raul Peixoto



    That would depend on how the custom css code was added.

    Are you using the standard api to enqueue a CSS file?

    If you are, FVM should merge it together and minify it.

    If not, the function you posted will work fine, until you uninstall FVM.

    You could replace your return with a function exists to prevent future errors:

    if(function_exists('fastvelocity_min_minify_css_string')) {
    return fastvelocity_min_minify_css_string($css);

    That way, it will minify if FVM is available and do nothing if you remove it.
    If you don’t do the function exists check… and remove FVM, you will have a Fatal error, since fastvelocity_min_minify_css_string would not exist.


    I’m not talking about the wp_enqueue_style CSS’s which FVM already handles.

    I’m referring to the Custom CSS that’s added via the UI.

    This CSS can eventually be post-processed by the ‘wp_get_custom_css’ filter before being outputted.
    Given that on my site I have a pretty large “custom CSS” block, minifying it saves several additional KBs, which can’t hurt 🙂

    Regarding the function_exists, you’re right. I’ve already added on my site (just after posting this 🙂 )

    Plugin Author Raul Peixoto


    Ha! The customizer 🙂

    I’ll add an option to minify that too in the future, but for now that function would be the way to do it.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Idea for an additional optimization (wp-custom-css)’ is closed to new replies.