tidy | compact | minify your html source code.

Posted by Damodar Bashyal on April 20, 2009


On next release I'll be adding html minify. This will remove unnecessary spaces and lines which are just the waste for bandwidth. The less size the file it loads faster. Also it saves bandwidth of the visitor. I have already applied to my site today. If you view the source code of this page you will understand what i am talking about.

Google's pages are compact, so probably it will like this idea and also other search engines. But of course this feature will be optional, which you can turn on/off for entire size and also set different on/off option for some controllers/pages.

This is how i set in MY_config.php

$config['cf_minify_html'] = true;

And, The controller:

//Get view data in place of sending to browser.
$html_string = $this->load->view("templates/$template/index", '', true);

//Process the html view source data

And, if you want to disable html compact for this pages generated by this controller, just add second parameter as false.

//Process the html view source data
$this->process->view($html_string, false);

I just need to dig more on this feature so, i will not be adding this today. I wrote this after release. So, i have atleast one more feature for next release :)

Actually i have css minify and combine too. This is quite intelligent then last one but not smart yet though. Need to find more better ideas for next time.

This concludes my codeigniter explore, learn and apply for today(actually for this week, as i'll have no time until next weekend.)

Happy Coding!!!
- CodeFight.org

not published on website

QR Code: tidy | compact | minify your html source code.