CSS Performance Tip #2 Browser Reflow & Repaint

This post has been inspired from:

Reflows & Repaints: CSS Performance making your JavaScript slow?

What is Repaint and Reflow?
A repaint occurs when changes are made to an elements skin that changes visibility, but do not affect its layout. Examples of this include outline, visibility, or background color. According to Opera, repaint is expensive because the browser must verify the visibility of all other nodes in the DOM tree. A reflow is even more critical to performance because it involves changes that affect the layout of a portion of the page (or the whole page). Reflow of an element causes the subsequent reflow of all child and ancestor elements as well as any elements following it in the DOM.

Reflows are very expensive in terms of performance, and is one of the main causes of slow DOM scripts, especially on devices with low processing power, such as phones. In many cases, they are equivalent to laying out the entire page again.

How to avoid reflows or at least minimize their impact on performance?

  • Change classes on the element you wish to style (as low in the dom tree as possible)
  • Avoid setting multiple inline styles
  • Apply animations to elements that are position fixed or absolute. They don’t affect other elements layout, so they will only cause a repaint rather than a full reflow. This is much less costly.
  • Trade smoothness for speed. What they mean by this is that you may want to move an animation 1 pixel at a time, but if the animation and subsequent reflows use 100% of the CPU the animation will seem jumpy as the browser struggles to update the flow. Moving the animated element by 3 pixels at a time may seem slightly less smooth on very fast machines, but it won’t cause CPU thrashing on slower machines and mobile devices.
  • Avoid tables for layout (or set table-layout fixed)
  • Avoid JavaScript expressions in the CSS (IE only)

CSS Performance Tip #1

As we all know that most of the browsers read our css selectors from right to left.

For example:

ul > li > a { color:#ff0000; }

Browser will first interpret anchor (a) tag and then will filter it in list (li) tag and later in unsorted list (ul) tag to apply color to (a) tag.

There are four kinds of key selectors: ID, class, tag, and universal.

ID (Ex: #main-title)     >>  Most Efficient
Class (Ex: .major)         >>  Second Most
Tag (Ex: a)                   >>  Third
Universal (Ex: *)          >>  Very Inefficient

In the example below, when we combine this right-to-left idea, and the key selector idea, we can see that this selector isn’t very efficient:

#main-list > li {   }    /*  is actually slower than it might seem  */ 

Usually, since ID’s are so efficient, we would think the browser could just find that ID quickly and then find the li children quickly. But in reality, the relatively slow li tag runs first in this case.

Do You Think Zurker is Better?

  1. Responsive:

    I found it quite easy to find the co-founders on Zurker (UserID’s Cineman and Berzurker). I am usually very sceptical so I always like to confirm and understand before I commit any of my precious time. I asked Cineman and Berzurker a many aggressive and demanding questions, and to my amazement they answered all my questions within a couple of hours with refreshing frankness and openness.

  2. Privacy:

    You can associate each of your contacts on Zurker with a “tag”. Tags could be “Friends”, “Family”, “Colleagues” or “Man Utd supporters” or any other tag you make up. Only you can see your tags, so you could tag someone as “Pushy” and they would never be aware- I’m not confident enough to use this sort of tag while Zurker is in beta!

  3. Open Books, Open Statistics, Open Bug-Reporting, Open Everything:

    You can easily find Zurker’s open books accounting which shows every penny coming in and every penny going out. This seems to be updated hourly. You can also see membership numbers by country, also updated hourly. There is a link to report bugs, you can see all the bugs reported and the developer’s response.

  4. Democratic:

    Because Zurker is owned its members, everything will be controlled by voting.

  5. Click Here to Join Zurker!

  6. Future Development, Features and Apps will be Driven By Members’ Ideas:

    Members will be able to suggest and vote on ideas

  7. Business and Personal Identities Kept Separate:

    On Zurker businesses will be known as “Entities” these will be kept separate from personal identities. When you make a connection on Zurker, you will know whether its with a real person or a business.

  8. No Spam and No Advertising:

    Zurker is very strict about controlling spam and has no adverts.

  9. Members like you!:

    Because Zurker is new and revolutionary it attracts bright, positive and forward looking people.

  10. Over 18′s only:

    Facebook allows 13 year-olds to join (in fact some of its members are much younger). Zurker is for grown-ups only.

  11. Owned By Its Members:

    It seems to me that the Facebook model works like this. Facebook members spend endless hours maintaining their profiles. Mark Z then uses this data to target adverts at members and makes himself very rich. Zurker is totally different, it’s owned by its members and they will decide the direction of Zurker and how any revenues/profits will be distributed.

Negative Aspects

  1. 1. Zurker is in Beta

    Zurker is in beta and there are some bugs. The bugs seem to be mainly non-urgent issues and as explained above there is open reporting of bugs and they are being resolved promptly.

  2. 2. Zurker is Small

    Zurker is still very small (especially in comparison to Facebook) so you are unlikely to find many of your friends or family on Zurker. However membership is growing fast. If you want to enjoy some of the control and positives of sharing ownership of your own social media platform then its worth trying it and asking some of your friends and family to join you.

  3. Bad User-interface

    After going through the website I realized that the current website running for Zurker India needs lots and lots of improvement in terms of user interface. The interface does not appeal to the user in the first go. However green themes can not be made better than the blue themes but still the use of latest jquery and ajax plugins could have improved the user interaction and leave a soothing effect.

  4. This writeup is inspired from Zurker Review – What is Zurker?.

ZURKER VS. FACEBOOK

It is believed that Zurker is going to be the one of the biggest rivals for Facebook.

Imagine if you had been offered the opportunity to own part of Facebook for zero cost, would you have seized the moment? You have a similar chance with Zurker right now. At the moment it’s in beta and membership is by invitation only, so here’s your invite:-

Click Here to Join Zurker!

Even though Zurker is in beta, membership is steadily climbing and today hit 10,000 members. In fact as I am writing this membership is 10,940 so over the last 24 hours over 1,000 new members have signed up. So don’t delay, please use my invite (see above) now!
Update; membership numbers are starting to go viral! As I write this (10th May 2012, 01:55 pm Noida, India) Zurker has 115,226 members and membership numbers are growing by 5,000 to 10,000 members per day.

Zurker membership stats

 

Zurker

What is Zurker?

One of my room-mate one late night asked me if I was aware of the Zurker one of the latest Social Network Website player coming here in India. I got up from the bed, started my lappy and started searching about the story and reviews about Zurker.

Zurker India

I was surprised to know the rumor behind its popularity: Zurker is owned by Winklevoss Brothers. No. it’s not.

Click Here to Join Zurker!

Cineman and Berzurker are the Co founders. You can find them at Zurker. It is currently in its Beta phase. It’s an open platform which can be trusted as it will be owned by you.

Zurker user becomes co owner

Yes, you are one of the owners. Zurker is an innovative social media website which is owned by its users. You can join Zurker by an invite from an existing member. Once you sign up you will be provided with a link which you can use to invite your friends and others into Zurker. The more people you get into it the more shares will be given to you. The concept is as the value of Facebook today is 100 billion $ after the IPO Zurker can also go miles. Then at that moment the value of your share will increase with time.

Facebook

  1. Branding – Facebook can be a great resource for generating brand awareness. Facebook is becoming popular amongst various age demographics and can be a create interception point for building your relationship with you consumers and prospects.
  2. Customer Engagement – Using Facebook applications can be a great way for communicating promotions, contest and events. Again it is another interception point that can be leveraged to entice consumer engagement with your brand, your products or your service.
  3. Drive Web Traffic – Facebook can act as a portal point for driving traffic to your site and other online properties.
  4. Reputation Management – can be a useful tool for seeing what users are saying about you and your brand. In addition your Facebook profile can now be indexed in the search results and as a result can provide another favorable listing in the organic search results of the engines.
  5. New Customer Acquisition – Facebook provides an opportunity to find consumers you may have not otherwise discovered.
  6. Lead Generation – Similar to the previous point is that Facebook can act as another potential lead gen tool that can be used to qualify leads. Reviewing potential prospects’ profiles may help you build a relationship with your prospects and aid in the lead generation qualifying process.
  7. Client Retention – provides another potential interception point to build the relationship with your consumer.
  8. Access to the social world and it’s inherent value – aka the cool factor. You never know who is using Facebook. Consider the following scenario: a potential prospect could be doing research on your brand or organization and may use Facebook to see if you have a presence there. Then they see that you have a Facebook profile and see a number of positive posts about your brand. This in turn can shape their sphere of influence and could end up being one of many deciding factors as to why the prospect selects you over another vendor. The perception that Facebook is “IN” and the fact that you are using Facebook could help influence their perception of your brand. Having said that, there are still may who are anti-Facebook so it could also affect the perception about your brand. The fact remains is that Facebook continues to gain popularity and it is not going away anytime soon.
  9. The Viral Effect – Take word Of mouth to a whole new level. Nothing attracts a crowd like a crowd… Facebook is attracting quite a crowd.
  10. Feedback Mechanism – Using Facebook and the various applications available can help you understand consumer behavior based on the sharing of content and commentary on the social networking site.
  11. Build Business Use Cases – Facebook can provide you with an opportunity to build successful business cases as you target specific vertical markets with specific business objectives.