Thanks for the explanation, Karl.  That makes a lot of sense.

Your chunking solution does seem to prevent the unresponsive
script errors when the page is loading.  However, I still get them
when I navigate away from the page -- I assume jquery is unbinding
all of the cluetips.

For that reason and to reduce overhead I will probably switch to
inline calls to a javascript function that will generate the cluetip.
But I'm happy to have the setTimeout trick in my arsenal, I'm sure
it will come in handy.

thanks again!
az


On Apr 2, 4:11 pm, "Karl Rudd" <[EMAIL PROTECTED]> wrote:
> JavaScript in browsers is "single-threaded" (and thank goodness for
> that). So when JavaScript is running (in most browsers) everything
> else is queuing up. When you break the code into chunks, via
> setTimeout, you are (essentially) "yielding" control back to the main
> event loop periodically, so it has time to "breath" and clear it
> various queues.
>
> Karl Rudd
>
> On Wed, Apr 2, 2008 at 8:04 PM, az <[EMAIL PROTECTED]> wrote:
>
> >  Thanks to both Karls for your help!
>
> >  I'll definitely try out the chunking method.  Since I'd like to
> >  understand what I'm implementing, can you briefly explain why this way
> >  is better?
>
> >  thanks,
> >  az
>
> >  On Apr 1, 4:59 pm, "Karl Rudd" <[EMAIL PROTECTED]> wrote:
> >  > You can initialise the tips in "chunks".
>
> >  > Instead of doing something like this:
>
> >  >   $('a.tip').cluetip();
>
> >  > Do something like this:
>
> >  > $('a.tip').each(function() {
> >  >   var t = $(this);
> >  >   setTimeout( function() { t.cluetip(); }, 10 );
>
> >  > })
>
> >  > You'll still have a bit of a CPU usage spike but it shouldn't totally
> >  > freeze the browser or bring up the "Running too long" type warnings.
>
> >  > Karl Rudd
>
> > > On Tue, Apr 1, 2008 at 12:38 PM, az <[EMAIL PROTECTED]> wrote:
>
> >  > >  Hello,
>
> >  > >  I have a dynamically generated page that can be long or short.
> >  > >  Everything is fine when it's short, but when it gets to be *very*
> >  > >  long, it gives unresponsive script errors.
>
> >  > >  I believe this is because each entry on the page contains 3clueTip
> >  > >  links.  If I have a thousand entries, that's 3,000 clueTips to bind
> >  > >  and possibly keep in memory and then unbind when the user leaves the
> >  > >  page.  That's a lot!
>
> >  > >  Any suggestions on how to prevent these errors?
>
> >  > >  My only thought is that instead of using jquery to bind the clueTips
> >  > >  at page load, I can do things the old-fashioned way and trigger the
> >  > >  clueTipby linking to a javascript function.
> >  > >  Something like:
> >  > >  <a href='javascript:clueTipFunction()'>link</a>
>
> >  > >  Will that work?
>
> >  > >  thanks,
> >  > >  az

Reply via email to