3

If I see a cool effect on a website I view the source of jquery and usually I can wrap my head around it ,however, I was looking at the slider for http://www.mckinsey.com and viewed the jQuery source that is used in doing the page slide: http://www.mckinsey.com/assets/dotcom/js/home.js

I can't seem to understand how this jQuery code is written or what it does, though, I do understand that it is written in a better fashion and can be maintained properly since everything is not inside the document.ready() function

  • Can someone break this code down a little to explain (I'm just concerned with slider not, not cookies)

  • Are there tutorials/books that show how to write/understand jQuery code written in this manner.

jack
  • 107
  • 1
  • 5
  • Actually it is not the jQuery code that matters here. You should dive deep into the beauties of the Javascript language. jQuery here is only used for what it is meant to be used for. – kapa Jun 10 '11 at 16:54

1 Answers1

1

This method and others like it are known as 'design patterns'. This particular one appears to be the Command Pattern. The following link has a great explanation of the more popular patterns, why they're useful and code examples:

http://addyosmani.com/resources/essentialjsdesignpatterns/book/

amustill
  • 5,274
  • 23
  • 15