“Even Faster Websites”

OReily Even Faster Websites is a great book. It has some Javascript perfomance hints in its “Writing Efficient JavaScript” part. Here are conclusions:

  • Use local variables
  • Avoid with statement
  • do not use too deep properies, redefine them with locals if possible
  • Use the if statement when:
    — There are no more than two discrete values for which to test.
    — There are a large number of values that can be easily separated into ranges.
  • Use the switch statement when:
    — There are more than two but fewer than 10 discrete values for which to test.
    — There are no ranges for conditions because the values are nonlinear.
  • Use array lookup when:
    — There are more than 10 values for which to test.
    — The results of the conditions are single values rather than a number of actions
    to be taken.
  • To improve perfomance of loops decrement the iterator toward 0 rather than incrementing toward the total length.
This entry was posted in post. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>