add minify feature in output class? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: add minify feature in output class? (/showthread.php?tid=64524) |
add minify feature in output class? - iz_no_good - 02-29-2016 hi all, please correct me if i am wrong, but i think CI doesnt have a minify feature for removing the whitespace chars from the html output before sending it to the browser, right? i see there are numerous libraries out there , but why not have one in the CI "core" as well? it would definitely be useful , and shouldnt be that complicated as well, unless i am missing something hereĀ and - needless to say - many thanks for the wonderful CI RE: add minify feature in output class? - skunkbad - 02-29-2016 It's actually not a bad idea. I could see it breaking people's inline JS, but it might be rare, and then they'd just learn a lesson on how to write better JS. There is this though: http://stackoverflow.com/questions/5362167/remove-whitespace-from-html See the accepted answer regarding gzip compression. RE: add minify feature in output class? - Narf - 02-29-2016 Actually, we tried that and it proved to be a bad idea. RE: add minify feature in output class? - Diederik - 03-01-2016 Why not just rely on a Apache module like mod_deflate or mod_gzip? RE: add minify feature in output class? - iz_no_good - 03-01-2016 (02-29-2016, 04:58 PM)skunkbad Wrote: It's actually not a bad idea. I could see it breaking people's inline JS, but it might be rare, and then they'd just learn a lesson on how to write better JS. well, ok gzip will compress the whole page, but if you have first stripped out the whitespace that would be the ideal. i tried one of the several libraries for minifying and indeed my inline JS got messed up, but without thinking it too much i thought this could be prevented by a better set of conditions in the preg_replace, right? js scripts do get minified and usually are packaged in minified, but again i didnt think of this any further, i was really curious why CI was not providing something on this, and decided to ask here about it RE: add minify feature in output class? - iz_no_good - 03-01-2016 (02-29-2016, 10:47 PM)Narf Wrote: Actually, we tried that and it proved to be a bad idea. i tried some of those libraries and have a feeling i know what you really mean but maybe we could have a standard minify function - well documented too - and then users should make sure their code complies with the "restrictions" to make it work, else they could end up in trouble? just a thought. RE: add minify feature in output class? - iz_no_good - 03-01-2016 (03-01-2016, 06:14 AM)Diederik Wrote: Why not just rely on a Apache module like mod_deflate or mod_gzip? i do use those but its not the same. minify should minify the unnesessary whitespace first and then the select apache module shall compress the whole page to transfer to the user. RE: add minify feature in output class? - Narf - 03-01-2016 (03-01-2016, 01:55 PM)iz_no_good Wrote:(02-29-2016, 10:47 PM)Narf Wrote: Actually, we tried that and it proved to be a bad idea. No, you don't really know what I meant - there literally was a 'minify_output' feature in CI 3.0-dev, for almost 3 years. And as I said, it proved itself to be a bad idea - it's not as easy as saying that we just need better regular expressions. In fact, trying to do it via regular expressions (because that's the easiest looking method) is what makes it a deceptively hard task. It's not a silver bullet. I was quite verbose with the commit message when the feature was removed: https://github.com/bcit-ci/CodeIgniter/commit/466e8ccb0ad647fd8e477e881dfddc14c6d7cbc8 ... and that's final. RE: add minify feature in output class? - iz_no_good - 03-02-2016 (03-01-2016, 03:38 PM)Narf Wrote:(03-01-2016, 01:55 PM)iz_no_good Wrote:(02-29-2016, 10:47 PM)Narf Wrote: Actually, we tried that and it proved to be a bad idea. ok.. now i understand .. "better", thank you for the details RE: add minify feature in output class? - allenlee - 05-23-2016 Hello.. I just made a library called "CI_Minifier". https://github.com/terrylinooo/CodeIgniter-Minifier Maybe it can help or give you more idea. |