Improve your jQuery - 25 excellent tips

http://www.tvidesign.co.uk/blog/improve-your-jque

Introduction



jQuery is awesome. I've been using it for about a year now and although I was impressed to begin with I'm liking it more and more the longer I use it and the more I find out about it's inner workings.

I'm no jQuery expert. I don't claim to be, so if there are mistakes in this article then feel free to correct me or make suggestions for improvements.

I'd call myself an "intermediate" jQuery user and I thought some others out there could benefit from all the little tips, tricks and techniques I've learned over the past year. The article also ended up being a lot longer than I thought it was going to be so I'll start with a table of contents so you can skip to the bits you're interested in.

Table of Contents






1. Load the framework from Google Code



Google have been hosting several JavaScript libraries for a while now on Google Code and there are several advantages to loading it from them instead of from your server. It saves on bandwidth, it'll load very quickly from Google's CDN and most importantly it'll already be cached if the user has visited a site which delivers it from Google Code.

This makes a lot of sense. How many sites out there are serving up identical copies of jQuery that aren't getting cached? It's easy to do too...

  1. <script src="http://www.google.com/jsapi"></script>  
  2. <script type="text/javascript">  
  3.   
  4.     // Load jQuery  
  5.     google.load("jquery""1.2.6");  
  6.   
  7.     google.setOnLoadCallback(function() {  
  8.         // Your code goes here.  
  9.     });  
  10.          
  11. </script>  
ry-25-excellent-tips.aspx
posted @ 2008-12-25 17:17  looping  阅读(270)  评论(0编辑  收藏  举报