Giter VIP home page Giter VIP logo

cakephp-minifyhtml-plugin's People

Contributors

bdossantos avatar ni-c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cakephp-minifyhtml-plugin's Issues

performance killer

Just for anyone that would actually use this:
On an average website - let's say 10k lines of html - the rendering rises dramatically from 5-10ms to over 150ms!
Do not use this plugin without being aware that the minifaction cost a magnitude of ressources more than just sending the non minified version.
It doesn't even minify everything, for example it has problems with embedded things like js code.

And instead of just whining, here a one liner that only has an impact of 60-80% and is actually doing better work:
return preg_replace(array('/ {2,}/', '/<!--.*?-->|\t|(?:\r?\n[ \t]*)+/s'), array(' ', ''), $html);

Don't minify non-HTML content-type responses

This may help people who see the minifier trying to get its hands on JSON responses. Throw this in your app controller's beforeRender()

// if the response is HTML then minify it
if ($this->response->type() === 'text/html') {
    $this->helpers[] = 'MinifyHtml.MinifyHtml';
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.