I had been getting the "A script on this page is causing Internet Explorer to run slowly" error in IE7. In my case, it only occurred after flushing the cache, when the Admin Menu was built and rendered as part of the page's HTML.

I was able to fix it with a patch to the jQuery selector that colorbox uses. It was this:

$('a, area, input', context)
   .filter('.colorbox')
   .once('init-colorbox')
   .colorbox(settings.colorbox);

I changed it to this (which, I think, is equivalent):

$('a.colorbox, area.colorbox, input.colorbox', context)
  .once('init-colorbox')
  .colorbox(settings.colorbox);

I think the second one is just more efficient (it doesn't need to filter on every link, etc.).

Comments

Status:Active» Needs review
StatusFileSize
new422 bytes

Here is the patch for the fix above.

Please run the following test and report back here:

http://jsperf.com/colorbox-selector-performance

When I run it on Safari, Firefox and IE 9 (in a virtual box) simply using the class as the selector is the fastest.

If you can confirm it I will make this change to all js in Colorbox.

StatusFileSize
new30.9 KB

I ran that test in IE7 on Win XP using Virtualbox (see attached). The one with ".filter('.colorbox')" was definitely the slowest.

StatusFileSize
new1.44 KB

Please test this patch that makes all js in Colorbox module use a single class selector. If it works for more people than myself I will commit it to all versions of Colorbox.

IE 7 is really slow with JavaScript it seems, modern browsers seems to have little problem with this but since a single class selector is by far the fastest I see no reason to not use it.

This patch works for me, but I'm not using "Colorbox load" or "Colorbox inline".

Status:Needs review» Fixed

Thanks for reporting and testing this!

I have committed the patch to both branches of 7-dev.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

This commit has caused a new bug to appear: #2154147: Conflicts with Colorbox and jquery <1.7 due to custom implementation of on(). Reverting the commit fixes the bug for me.

I would reopen this issue, in the interest of finding a better working solution, but since I've already put so many details and notes on the other one, I suppose we can leave this as closed. :-/

Issue summary:View changes
StatusFileSize
new1.47 KB

I think a patch similar to my original one in #1 above may fix this issue without causing the problem in #2154147: Conflicts with Colorbox and jquery <1.7 due to custom implementation of on().

I've attached a patch that still omits the call to filter(), but includes "a", "area", and "input" in the selector. I can't really test the fix in IE very easily any more, but Colorbox still works fine with this in place.

@jrb, i was mistaken on #2154147: Conflicts with Colorbox and jquery <1.7 due to custom implementation of on() to say that that issue was caused by this one. I'm sorry for causing you to spin extra cycles on this.