Tellibus.com, Now On Yii :)

There should be an equivalent in your language to our local proverb that goes like “the butcher is having turnip at dinner” :)

We’ve finally released our company’s website on Yii, including a blog and a mobile version.

On the app part, it’s really based on the blog demo, so we didn’t need any fancy extension.

We’re using a slightly-adapted 960.gs 12-column grid, Font Awesome font for icons, and quite a bunch of front-end optimization techniques that we’ve learned over the time. On the back-end, it’s a normal Linux-based shared host, with no back-end optimization till now.

The mobile version is a one-column custom —but not separate— one, meaning that the controllers and the views serve slightly adapted content, of course on the front-end, CSS is different from the desktop version, more or less like RESS, but not entirely, as it’s not responsive web design, images and other inline stuff are responsive though.

In the mobile version, we serve Zepto instead of jQuery, and so have adapted (and pushed to Github) some jQuery plugins, included some used by Yii.

Our credo is also WPO:

4276

GTmetrix-report-tellibus.com-20130517T102137-nSWgwZTH-full.png

Full report: http://gtmetrix.com/reports/tellibus.com/nSWgwZTH

Cheers!

A. Bennouna

PS Loving Yii more and more!

We say “the dyer is wearing écru pants” in Japanese. :)

Great!

How do you minify the outputs?

Nice saying!

Static resources (ie all external css, js, webfonts) are minified and compressed beforehand and stored in minified and min+gz versions, the .htaccess makes sure to serve the gz if supported by the browser, with the correct type mapping, mind you.

HTML is minified by overriding the render() method in the Controller’s base class, and adding a regex to remove unnecessary spaces. I’ve found such scenario for sure on the forum.

I’m on my mobile now. But I can post that code when I access my laptop.

So it basically goes like that:


public function render($view, $data = null, $return = false)

{

    $output = parent::render($view, $data, true);

 

    $replace = array(

        "#(?!\<\!--\[if)(<!--.*?-->)#s" => ""  ,  // strip comments except IE conditionals, which I use to load html5shiv or Google ChromeFrame

        "#> +<#"                        => "> <", // strip excess whitespace

        "#\s*\n\s*<#"                   => "<" ,  // strip excess whitespace

        "#>\s*\n\s*#"                   => ">" ,  // strip excess whitespace

    );

 

    $search = array_keys($replace);

    $html = preg_replace($search, $replace, $output);

    $output = trim($html);


    if ($return) {

        return $output;

    } else {

        echo $output;

    }

}

I’ve kept a note saying that “inspiration came from reading the following links”:

Thank you for sharing a valuable tip!! :)