Some "speed/design" tips


cause i like yii. I want to share some infos about "speed". Most of them are general tips, independent of the "language"

If you want to check ture/false in "if" you should try to check against 0. Its faster. The only exception is PHP where the check vs 1 is faster.

Garbage collection is your friend. If you set and unset on your own. The GC try the "same" which double the work. Only "unset" destroy if you have object over 10MB ( Depends on langugae, so far as i know this is the PHP value )

In a for loop dont count and check for example: ( In general )

for ( X+1; x <= count ( array/string ); x++)


y = count ( array/string)

for ( x+1; x <= y; x++ )

well, you would say this is just 10ms BUT if a script is thousand of times executed count on your own ( Note: scalability )

try to do queries at the end of script ( or other external things like soap/ xml ) So the user see something when it may"stop"

This is  more "ui" related, try to build with as less points as possible. And everything reachable with two clicks

The points thing. An example:




[td]THING ONE[/td]

[td]THING TWO[/td]



[td]THING THREE[/td]




Better like this:



[td]FIELD ONE[/td]

[td]FIELD TWO[/td]

[td]FIELD THREE[/td]



So the eyes have to move "less"

Numbers should be right aligned so they could be counted.

Try to use around "4-6" colors only. More is so called noise. Unneeded things.

If you design tables with "much" data lines. Use the "zebra" style. ( Cycling colors, with just a "slight" brighter and darker background )

Determine if the table is scanned ( read ) Vertical or horizontal. Try to "aid" the eyes. With those line. If both is used DONT USE LINES. The zebra helps, the rest is just noise.

[Edit] Forgot to something. Every five rows, add space between the rows. For better orientating.

The so called F navigation system is the most excepted "site style"

Top navigation, left sub navigation, and in the middle the content.

If you have to redesign a UI/ website. And if it has many users:

Ask theme what should be changed, what is annoying.

Try to keep the structure. Dont rebuild the navigation positions ( Only if they "sucks", For example you need four clicks to reach something )

Use everywhere the same header and bottom design. So the user knows where  the content starts and ends.

The most start position for a mouse on a website is top left.

The eyes move from: Dark to bright, from big objects to small objects.

movement binds the user to look at. so try to create movements which "aid" the eyes. Simplest examlpe a arrow. AND FFS stop the movement after 2 secs or less. ( OR if there is no way to stop it, or it must move) add a stop button and make it "slow". For example the moving M in the editor should stop or moves slower or on mouse over ( Best way) :wink:

So dont use big "rectangles" where you just place "eye candy"

Dont use: DIGG, SHARE THIS, and other things on your page. Only if you have more then thousand visitors per day. (Its just noise) If a user likes something he want to share, he opens the site!

And to SEO, just do the title URL, keywords and description optimizing. Content is very "unusual" rating. ( PR is more important ) And you dont need visitors which come and go ( Cause the content looks strange )

Ouch I wanted to write less but it grows ( Sorry for my bad English)

I hope it helps here and there.

If you have questions, feel free to ask. I am not a Dr. or a pro in it.

But its my "hobby"  :wink:

thanks for sharing

How about creating a cookbook article about this?

what did you mean about a cook book? A wiki? Or here in the yii cookbook?

Look here:


But maybe here's a good place also. I think the cookbook articles are more Yii specific.

So here are some more tipps:…ion-Tricks.html…imizing-php.php

Yeah a much better place :wink:

Lots more useful stuff here:

These are some very good tips!