A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

jQuery Tips

Got this from Reddit.

  1. Load the framework from Google Code
  2. Use data method and avoid storing data inside the DOM. Some developers have a habit of storing data in the HTML attributes
  3. Use Cheat Sheets
  4. Compress Javascript files
  5. Use Firebug
  6. Use ID as Selector whenever possible
  7. Use Tags Before Classes
  8. Cache jQuery Objects
  9. Bind certain jQuery functions to $(window).load event
  10. Use Chaining to limit selectors, make the code more simple and elegant

The complete article can be found in Tripwire Magazine.

This entry was posted in General and tagged , . Bookmark the permalink.

One Response to jQuery Tips

  1. While I agree with most of the points, I would:

    - take loading the framework from Google Code with the pinch of salt. If you are developing intranet applications in enterprise environment, e.g. reporting systems, there is a high probability that the application would need to be accessed via VPN connections. In this, loading the framework from Google or any other CDN would probably fail as it will not pass VPN authentication.
    - practically bind ALL jQuery functions that traverse/manipulate DOM after the document has been loaded, to ensure no JavaScript errors occur due to trying to access elements that haven’t been loaded yet.

Leave a Reply

Your email address will not be published. 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>