Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.).
Comment | File | Size | Author |
---|---|---|---|
#9 | 1910162-9.patch | 1.47 KB | jrb |
#4 | jquery_selector.patch | 1.44 KB | frjo |
#3 | 1910162-colorbox-selector-performance.png | 30.9 KB | jrb |
#1 | 1910162-1.patch | 422 bytes | jrb |
Comments
Comment #1
jrbHere is the patch for the fix above.
Comment #2
frjo CreditAttribution: frjo commentedPlease 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.
Comment #3
jrbI ran that test in IE7 on Win XP using Virtualbox (see attached). The one with ".filter('.colorbox')" was definitely the slowest.
Comment #4
frjo CreditAttribution: frjo commentedPlease 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.
Comment #5
jrbThis patch works for me, but I'm not using "Colorbox load" or "Colorbox inline".
Comment #6
frjo CreditAttribution: frjo commentedThanks for reporting and testing this!
I have committed the patch to both branches of 7-dev.
Comment #8
jwilson3This 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. :-/
Comment #9
jrbI 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.
Comment #10
jwilson3@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.