Friday, February 26, 2010

Object Oriented Java Script

Java Script probably one the dangerous funny language. The cleaner code you will write less surprises you will get. It has been in discussion that, use less javascript code to run your application faster. But, its not that at all. Many of the sites like MyYahoo, iGoogle have proven this wrong. They have created Portal with the help of javascript frameworks & just see the performance of these sites.

So, one thing we thing we can learn from these sites that its all depend on the way we are writing our code. There are so many documents stating about the best uses of java script. Some of them I will write below.

  1. In normal practice when we include a javascript file we do it in the header element of our page.
  2. But best practices says you do it in your last part of your page.
  3. Try to load your javascript file asynchronously. (I will give some examples in my next post)
  4. If you have an advantage of using javascript libraries like dojo/jquery/yui, then use their function which are similar to window.onLoad. (e.g. dojo.aaddOnload())
  5. Try to use object oriented concept in javascript. Some links are given below.
http://www.javapassion.com/ajax/JavaScriptBestPractices.pdf
http://nefariousdesigns.co.uk/archive/2006/05/object-oriented-javascript/

Please go through the links & share your thoughts. Because its us who will make some difference.

Please share your knowledge...

Thanks in advance...





No comments:

Post a Comment