AW: [Catalyst] Compress HTML

Stefan catalyst at s.profanter.me
Sun Sep 11 08:41:13 GMT 2011


Hi Bill,

I'm using the PageSpeed Plugin (from Google) in Firebug for Firefox. This
plugin measures the page speed and gives you some hint, how you can increase
the performance of your site.

And Google said, that they will also evaluate your page speed/performance
for page ranking because they want to make a faster internet.

 

One of the hints hint was, to minify the HTML source. So I did it and now
I've managed to get 100 points of 100 J

 

I'm also compressing with gzip (done by Apache), which is also a hint on
PageSpeed.

 

I think the combination of both is the best, because gzip compresses the
whole file to send over the net. And minify reduces the content which the
browser has to parse (also removes comments).

 

Stefan

 

 


use HTML::Packer;
use JavaScript::Packer;
use CSS::Packer;

my $html_packer = HTML::Packer->init();

sub process {
            my ( $self, $c ) = @_;
            my $rendered = $self->render($c, $c->stash->{template});
            my $opts = {
                        remove_comments => 1,
                        remove_newlines => 1,
                        html5 => 1,
                        do_javascript => 'best',
                        do_stylesheet => 'minify',
            };
            $html_packer->minify( \$rendered, $opts );
            $c->response->body($rendered);
}


_______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/ 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110911/83b199b8/attachment.htm


More information about the Catalyst mailing list