i’m having trouble with modifying the location hash in IE8 for XP. simply calling:
self.location.hash = "whatever"
takes about 800ms~1800ms
I have no idea what can slow this down. I checked the same instruction on some other sites and it’s not that slow.
Any clues what can make it so slow ? I am sorry but I can’t give an online example.
EDIT:
Here’s What I get in the IE console, input:
console.log( new Date().getTime() );
self.location.hash = "sfdsd";
console.log( new Date().getTime() );
output:
JOURNAL : 1326468325447
JOURNAL : 1326468327390
undefined
which makes almost 2000ms, if I read correctly, for a single assignation :/ .
EDIT2: since it doesn’t seem clear enough, more preofiled code:
var profileThat = function() {self.location.hash = "whatever"};
$('#keywatchHeader').click( profileThat );
profiler results with two clicks:
profileThat 2 3475,00 3475,00 hidden 4 50,07 50,07 http://192.168.0.30/kw5/js/jquery/jquery-1.6.2.js 6 608 eventHandle 8 3525,07 40,06 http://192.168.0.30/kw5/js/jquery/jquery-1.6.2.js 2 595 get 4 20,03 20,03 http://192.168.0.30/kw5/js/jquery/jquery-1.6.2.js 6 419 get 6 10,01 10,01 http://192.168.0.30/kw5/js/yui2/dom/dom.js 96
EDIT3:
I ran some tests on node number on tree out of curiosity and results are surprising. After such a call:
document.getElementsByTagName('*').length; //3621
$('#keywatchPanels').children().remove();
document.getElementsByTagName('*').length; //332
after that the profiler gives 600ms instead of 1700ms per call! But I hardly with node number would influence hashtag writing.
(edit4):I’ve found this related question: Why is this piece of Javascript code so slow? (but the answer here is just “remove it”)
Finally, i’ve found my answer in a comment of an answer of a related question:
Why is this piece of Javascript code so slow?
– Aistina May 7 ’09 at 9:22
Why didn’t I though about it earlier ?