• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
add minify feature in output class?

#1
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  Big Grin

and - needless to say - many thanks for the wonderful CI Cool
Reply

#2
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/53621...-from-html
See the accepted answer regarding gzip compression.
Reply

#3
Actually, we tried that and it proved to be a bad idea.
Reply

#4
Why not just rely on a Apache module like mod_deflate or mod_gzip?
Reply

#5
(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.

There is this though: http://stackoverflow.com/questions/53621...-from-html
See the accepted answer regarding gzip compression.

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 Smile
Reply

#6
(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 Cool

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.
Reply

#7
(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.
Reply

#8
(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.

i tried some of those libraries and have a feeling i know what you really mean Cool

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.

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/c...14c6d7cbc8

... and that's final. Smile
Reply

#9
(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.

i tried some of those libraries and have a feeling i know what you really mean Cool

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.

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/c...14c6d7cbc8

... and that's final. Smile

ok.. now i understand .. "better", thank you for the details Smile
Reply

#10
Hello..

I just made a library called "CI_Minifier".

https://github.com/terrylinooo/CodeIgniter-Minifier

Maybe it can help or give you more idea.
Personal blog: https://terryl.in
My personal project is called Dictpedia is currently using Codeigniter 3, welcome.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.