Yii Framework Forum: Content Compacter - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Content Compacter Compresses HTML, inline CSS and JS

#1 User is offline   sAe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 18-May 09
  • Location:Sweden, Karlstad

Posted 16 May 2010 - 08:50 PM

Hello,

I've created a wrapper extension to a class that minimize bandwidth usage when parsing output to clients.
Made this mostly out of interest so haven't used this in any large-scale applications yet but i can definitely see some benefits of having this in future projects.

Content Compacter removes unnecessary whitespace, intendents and rowbreaks in your rendered viewfiles. It also compresses inlined CSS and JS in your HTML using borrowed code from minify. It can also remove HTML conditionals specific to IE when detected browser isn't IE.

For examples and download, click here and i shall magically transfer you to the extensions page! :rolleyes:


/Martin


Edit: I stripped out a few methods from the original class because they were not the Yii-way to do it. Especially their implementation of gzip output, i've seen better solutions and extensions to this, which also is a perfect way of saving even more bandwidth.
0

#2 User is offline   Gosaric 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 02-December 10
  • Location:Croatia

Posted 09 January 2011 - 12:04 PM

Compactor.php:286

I think it's better to put a space instead of empty string in the second argument.

Like this:

return str_replace($this->_options['line_break'], ' ', $html);

You'll see why if you use the default template (or any other, but it is also possible to see on the standard).
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users