Posts: 8
Threads: 1
Joined: Feb 2016
Reputation:
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
and - needless to say - many thanks for the wonderful CI
Posts: 1,299
Threads: 62
Joined: Oct 2014
Reputation:
86
02-29-2016, 04:58 PM
(This post was last modified: 02-29-2016, 05:00 PM by skunkbad.)
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.
Posts: 1,589
Threads: 1
Joined: Oct 2014
Reputation:
121
Actually, we tried that and it proved to be a bad idea.
Posts: 300
Threads: 0
Joined: Jan 2015
Reputation:
20
Why not just rely on a Apache module like mod_deflate or mod_gzip?
Posts: 8
Threads: 1
Joined: Feb 2016
Reputation:
1
(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
Posts: 8
Threads: 1
Joined: Feb 2016
Reputation:
1
(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.
Posts: 8
Threads: 1
Joined: Feb 2016
Reputation:
1
(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.
Posts: 1,589
Threads: 1
Joined: Oct 2014
Reputation:
121
(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
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.
Posts: 8
Threads: 1
Joined: Feb 2016
Reputation:
1
(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
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. 
ok.. now i understand .. "better", thank you for the details
Posts: 23
Threads: 8
Joined: Mar 2016
Reputation:
2
Hello..
I just made a library called "CI_Minifier".
https://github.com/terrylinooo/CodeIgniter-Minifier
Maybe it can help or give you more idea.
|