The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Change Classes not Styles

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Amos King

Posts: 78
Nickname: adkron
Registered: Jan, 2007

Amos King is a Web Developer for the US Postal Service and for Ramped Media.
Change Classes not Styles Posted: Nov 4, 2010 8:08 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Amos King.
Original Post: Change Classes not Styles
Feed Title: DirtyInformation
Feed URL: http://feeds.feedburner.com/Dirtyinformation
Feed Description: Information about Ruby/Rails/JRuby/WebDevelpoment/whatever.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Amos King
Latest Posts From DirtyInformation

Advertisement

I've been working with some javascript lately and wanted to see if it made a difference if I was changing the class or inline style of an element. I had heard that changing classes was faster, but can it really make a big difference?

YES!!!

I coded up a quick example. Here are the results in ms(all on osx):

  • Safari 5.0.2
    • changing style:123
    • changing class:15 - 87.8% faster
  • Chrome 7.0.517.44
    • changing style:115
    • changing class:16 - 86.1% faster
  • Firefox 3.0.15
    • changing style:333
    • changing class:99 - 70.3% faster
  • Opera 10.10
    • changing style:554
    • changing class:111 - 80% faster

I really didn't expect those kinds of results. Kind of amazing!

Read: Change Classes not Styles

Topic: Do You Understand Ruby's Objects, Messages and Blocks? Previous Topic   Next Topic Topic: How Does One Use Design Patterns In Ruby?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use