> 1) Where can I find a searchable archive of this mailing 
> list, because I'd hate to ask questions that have already 
> been answered.

Here are a couple:

http://www.google.com/search?q=site:jquery.com+optimize+OR+optimization

http://www.nabble.com/JQuery-f15494.html

> 2) I'm getting about a 1.5 second pause when the page loads 
> up, even when on my local system, which appears to be when my 
> jquery commands execute.  It's just a little too long, my 
> client noticed right away.  Are there any tricks to help this 
> out?  For example is it better to use xpath or css type 
> searches for better performance?

It's better to not do the searches at all - or rather do them only once. I
see a lot of code where the same jQuery expression is repeated over and over
again - whether it's inside a loop or simply repeated in the code.

Instead of:

   $('.foo').something();
   // other code here
   $('.foo').somethingElse();
   // how about a loop
   for( var i = 0;  i < 42;  i++ ) {
      $('.foo').andSomethingElse();
   }

Write:


   var $foo = $('.foo');
   $foo.something();
   // other code here
   $foo.somethingElse();
   // how about a loop
   for( var i = 0;  i < 42;  i++ ) {
      $foo.andSomethingElse();
   }

That code will be a LOT fater than the first.

I like to use the $ prefix on the variable name when I save a reference to a
jQuery object - it makes the code still look like jQuery code to me. :-) For
a single element, it can be useful to save references to both the jQuery
object and the underlying DOM element. I like to use the same variable name
for both, with the $ prefix on the jQuery object. This makes it easy to see
their relation in the code:

   var $moo = $('#moo'), moo = $moo[0];
   $moo.jQueryMethod();
   moo.domMethod();

> I know this is a pretty open ended question please let me 
> know if I can help clarify it.  If I can get this performance 
> thing fixed up a bit I hope some of my plugins can be useful 
> to the community.

If you're going to be releasing your code anyway, just post it somewhere and
we can all take a look at it. Otherwise you'll just get general suggestions
like these.

-Mike


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to