Archive for the ‘Internet’ Category

Web Site Performance Optimizations

Monday, February 22nd, 2010

Recently I have done some optimizations to make telvee a little faster using django_compressor and making sprites for background images. Good news is substantial changes to development environment and the design wasn’t required. I’ll get into details below. But first I’d like to write about the theory a little bit.

I follow (and read with great interest) Steve Souders’s blog High Performance Web Sites. I must admit I was sceptical about it at first; spriting images, individual different loading behaviours of browsers… I thought they were premature optimizations. But I realized I was wrong as I continued to read. Steve Souders is an expert on high performance web sites and what he preaches are realistic techniques, backed by test results most of the time. If you are not following, I suggest you add it to your RSS reader.

Optimization Techniques

We can explore the techniques in two main categories:

  1. Techniques to reduce the data to be transferred.
    • Minifying: Minification is removing comments and unneeded whitespace in CSS and JavaScript files. Compilers like YUI Compressor and Closure modifies JavaScript code to compress even further, without any changes to the functionality.
    • Gzipping: Web browsers accept gzip encoded content for a long time. I have just compressed a 13 KB text file down to 4 KB. A two thirds compression ratio is not bad at all.
  2. Techniques to reduce the number of HTTP requests.
    • Combining: CSS and JavaScript files can be combined together into a single file and therefore a single HTTP request. Gzip may be more efficient on these files. In a similar way background images can be merged into a sprite and then reconstructed again using their coordinates on that sprite.
    • Data URI’s: Images (or other file types) can be embedded into CSS (or JavaScript or HTML) using data: URI’s. Extra HTTP requests for those resources can be avoided this way.

You might think it’s fine to perform all these optimizations, but what happens when I want to make some changes to my combined, minified JavaScript file? Instead of applying these techniques blindly, it’s best to follow a sensible plan for implementing these optimizations:

  • First of all everything that can be automated should be automated. Regarding the example above script files should stay uncombined and uncompressed in the development environment and optimizations should be applied when the application is published. Taking it a step further we can have the application detect changes in those files and update optimized versions automatically. (django_compressor works this way)
  • I was worried that spriting would complicate managing the design. But I have seen, on the contrary; if images each sprite contain are choosen carefully it makes the process easier. Start combining images that belong to the same design element. Avoid complex arrangements, stick with horizontal or vertical stacking as much as possible. Don’t forget to leave transparent spaces between items and sprite border. Try to combine images that are loaded on the same page, avoid loading a sprite for only half of it’s elements. Don’t force yourself to combine all images, if you follow the guidelines I have mentione they won’t.
  • When performing optimizations don’t forget to use easily available tools. You can use YSlow for general analysis, SpriteMe for image combining tips, CompressorRater to compare different compilers’ performance on your scripts. I would like to note that Steve Souders is the developer of first two.

Telvee Results

I didn’t think about performance at all when I started developing telvee. Too many CSS files and too many images were being loaded. Here is what it looked like before optimizations:

 # of requestsload (KB)
Homepage25~85
Cup Detail48~80

Then I have installed and configured django_compressor. I used YUI Compressor for both JavaScript and CSS. I have created sprites and modified CSS files manually1. Then I deployed these changes and measured again:

 # of requestsload (KB)
Homepage12~70 (~160)
Cup Detail14~64

In the load column of Homepage, the number in parens is the actual load. But the design of homepage is changed with this upgrade and a new 90 KB image is being loaded now. So I have accepted 70 KB in my calculations. The result of optimizations are as follows:

 # of requestsload (KB)
Homepage52%17%
Cup Detail70%19%

Django_compressor and Data URI’s

Django_compressor, developed by Christian Metts, helps you to apply optmizations I have mentioned above easily to your Django projects. You can see my fork here where I have merged some other branches and added a little bit of code myself.

Using compressor.filters.datauri.CssDataUriFilter in data-uri branch of this repository, you can embed linked files within your CSS files. It will only embed files less than or equal to 1024 Bytes (1 KB) by default. You can change this limit by setting COMPRESS_DATA_URI_MIN_SIZE in your settings.py.

There are a couple of things to pay attention when you convert your references to data: URIs. Firstly file contents are base64 encoded which means approximately one third increase in size. It’s up to you to balance between increased bandwidth and reduced request counts2. Another thing to watch for is multiple references to the same file will end up embedding the same data many times. The solution to this problem is to reduce all references to one3 but this might break your CSS arrangement strategy.

Please test django_compressor’s data: URI support and tell me what you think. If you haven’t applied optimizations I mentioned above, you should. Thanks to django_compressor they are quite easy to implement on Django projects.


1: I would like to add automatic sprite building/linking support to django_compressor sometime.

2: With Today’s modern connections 1~2 KB increase is a good price for 1 less HTTP request..

3: http://meiert.com/en/blog/20090401/why-css-needs-no-variables/

Bookmark and Share

ProFORMA: Probabilistic Feature-based On-line Rapid Model Acquisition

Friday, November 13th, 2009

I came across this amazing research project via @dogacan today. The technology described is a combination of video tracking and image-based reconstruction. Watch the video below, it’s awesome!

The final model has some minor artifacts (especially in concave sections) but very nice looking otherwise. I wonder how well it handles complex geometries and deep cavities.

They say, in the project page, there will be a Linux-based demo released in a few months. You can leave your e-mail there if you want to get notified.

Bookmark and Share

XING Türkiye Social Media Win

Thursday, November 5th, 2009

I had a small issue with XING recently. I had reported this stupid message sent to an unrelated group. I’ll try to translate a snipplet below:

I have sent XING two messages to cancel my account, I don’t want to be a member.

I would like to take advantage of XING’s unique potential to bring people together, until they cancel my account, to help homeless children and elders.

WTF! This was supposed to be a business related group. If anybody and their aunt will spam all 15k members; thank you, but no, thank you. So I did what any responsible user would do and used the report spam thingy.

Here is what I had hoped to happen; my report is stored somewhere. Other people flags this as well. When a critical number is reached a moderator reviews if the message is really spam and takes the appropriate action.

Here is what happened; an hour later or so I got an e-mail. It said “if you don’t want to receive messages from this person do yak yak yak”. King-size WTF.

  1. First of all I had already done that. He should have checked if I did before writing an e-mail.
  2. More importantly, he should have checked my profile for a second. It says programmer. So, if I’m a programmer I am supposed to know a thing or two about these computer thingies, right? Clicking, double-clicking, expertise on check boxes and stuff. Telling me how to block a user is the same thing as saying “hey muhuk, you’re an idiot”. Even if we suppose there are such morons1, you still don’t have to tell it to their face. If you don’t have anything useful to say, don’t say nothing.

As a result, I got pissed of and sent this tweet:

XING Türkiye Support is clueless. Make sure you know who you’re e-mailing + take a moment to check if your advice has already been applied.

This is not the end of the story though. I received an e-mail from XING Community Manager yesterday. It was a very polite message containing the acknowledgement of both issues2. Nothing out of the ordinary at first sight. But wait, the message mentioned my tweet. In the very beginning. Actually the first word was “Twitter”. And it was concluded with something along the lines of “keep sharing your comments”.

Well, of course my comments and ideas are worthless. Especially since I’m not a very active XING user. But don’t miss the important point here: XING basically, via it’s community representative, says “you tweeted a negative tweet about us, but we are cool with that”. Why is it so important?

  1. They seem to be really cool about that. That means they understand social web. Conventional thinking is “I’d prefer you told this to me directly”, “we could have solved it between you and me”, “why do you shout, you make me look bad”. I have seen supposedly social media aware brands do this. It doesn’t look good. Trying to silence people is a horrible idea.
  2. You can win people easily. Beautiful thing about Internet (and online services in particular) is that no party has too much power over the other. You can’t intimidate someone because she doesn’t like your services and writes about it. On the other hand she can’t do much damage3. So instead of freaking out, try to be nice and convert naysayers to evangelists.

Most of the time complaining customers want to know there is someone who can see things from the right perspective. Someone reasonable, agreeable, fair. Most of the time that’s all that is needed to turn “<your brand> sucks” to “sh*t happens, no big deal”. My perception changed from “clueless” to “hmm, I guess that was a misstep of an individual” to “wow, appereantly XING Türkiye knows social web very well”. And all it took was a simple e-mail4. It’s not that difficult.

Kudos to XING for being a good web2.0 citizen.5


1: I mean programmers who couldn’t figure out how to use a web GUI. People from other professions might not know these and that’s not necessarily their problem.

2: What more could a user/customer hope other than acknowledgement? The message also contained an apology. But, I personally don’t think brands should apologize to their customers. Especially regarding to freemium services.

3: This is true even for big players like TechCrunch.

4: I bet it’s instantiated from a draft, everybody gets more or less the same message. This makes it even cooler though.

5: And special thanks for making me feel like a jerk. Just kidding, feelings are for losers. ;)

Bookmark and Share

New Project: Telvee

Wednesday, October 28th, 2009

I have been working on telvee for a few months. To be precise gitk tells the initial commit was at 2009-06-24 16:20:38. I have been meaning to write about it but just couldn’t find the time (or should I say couldn’t drag my lazy ass to do it). Anyway. I have marked version 0.3 for telvee today and here it is.

Telvee is a social toy built around the idea of coffee grounds reading. No, it is not a fortunetelling application. Telvee is intentionally dumb in that sense. It generates an image of the remains inside a coffee cup. Looking at this image, users write fortunes for other users’ cups. This is the basic idea.

What if you don’t know anything about coffee reading? Well, we have a 12 step program that… No, no. If you don’t have proper coffee reading skills just make something up. Telvee is after all nothing more than a social toy. I am very passionate about coffee reading. I can’t tell a fortune. But I can drink the coffee, turn the cup and listen to my fortunes. This has worked pretty well for me in real life. We’ll see how it works out on the Internet when telvee is launched.

As you might have guessed telvee is a Django project. I am happy to work on a well organized, clean and well tested (91% coverage) codebase.

What Works?

Basically all the main functions are in place:

  • Cup image generated
  • You can write fortunes
  • You can moderate fortunes (but blocking is broken)
    • Deleting, recovering, liking, unliking…
  • You can write comments
  • You can delete comments (but blocking is broken)
  • Friending works
  • You can block users (but it doesn’t have any effect for now, hence broken)
  • Invitations work (but, currently hidden from testers)
  • Account management works (but, incomplete)

What Needs To Be Done?

Aside from critical functions I haven’t thought of:

  • A blog
  • Groups
  • Improvements on many pages including homepage
  • Django goodies that has little to do with frontend experience.

When Will It Be Finished?

Probably never. But I would like to initiate a proper beta this year. And then launch as soon as possible, maybe before summer. It is currently tested by a tiny group of people. I will start sending invites as soon as I decide it’s reasonably embarrasing.

If you would like to try telvee; please leave your e-mail at http://www.telvee.com.

Bookmark and Share

Science Fiction: Text-to-Movie

Thursday, October 15th, 2009

It’s a really strange feeling, what you read in sci-fi stories coming true. First they made it possible to generate believable images purely out of bits and pixels. And now you can create a complete animation just with a movie script.

I have stumbled upon STATE via sjjh today. Check out the demo.

I wonder what will be possible next? Hopefully not immortality. There are too many cool things to discover before.

Bookmark and Share