Runtime minifyer for CSS and JS

Bjarne Varöystrand shared this idea 1 year ago
Under Consideration

Would be good for speed if Koken could minify the theme CSS on "the fly"

Comments (4)

photo
1

This sounds like a simple and fast way to achieve a snappier Koken:

https://ikreativ.com/combine-minify-css-with-php/

  1. <?php

    header('Content-type: text/css');

    ob_start("compress");


    function compress( $minify )

    {

    /* remove comments */

    $minify = preg_replace( '!/*[^*]**+([^/][^*]**+)*/!', '', $minify );


    /* remove tabs, spaces, newlines, etc. */

    $minify = str_replace( array("rn", "r", "n", "t", ' ', ' ', ' '), '', $minify );


    return $minify;

    }


    /* css files for combining */

    include('reset.css');

    include('application.css');

    include('responsive.css');


    ob_end_flush();

photo
1

Adding some further "reading" to the list:

photo
2

These online cssminifier and javascript-minifier I have used and really work well. But it is a little more work having to copy paste and then upload the whole css again and again. so builtin minifiers will be really good and useful in the core.

photo
1

Was not meant as a "replacement" for a built in solution: more as a pointer to tools that could be used in Koken.

I.e clean-css that is used by the cssminifier.com