I'm working on a portfolio redesign and I have a bit of JS that generates a large number (around 300) of divs, styles them, and appends them to body. This works quickly and perfectly in webkit browsers, but when it comes to Firefox it's slow as hell.
I've been trying to figure out why Firefox can't handle this, and I tried concatenating all the divs' html as strings and then appending the whole thing to body, but this proved to be just as slow or slower.
If you'd like to see the problem live, my site is here
Here's the relevant bits of code:
get_bokeh returns a string of CSS styles describing a single "bokeh" piece.
function generate(){
$("#bokeh_container").remove();
if (q==0){
min = 30,
max = 30,
bokeh_count = 1;
}
else if (q==1){
min = 7,
max = 10,
bokeh_count = 300;
}
else if (q==2){
min = 7,
max = 15,
bokeh_count = 300;
}
else if (q==3){
min = 8,
max = 11,
bokeh_count = 500;
}
sum = min+max;
window_width = $(document).width();
window_height = $(window).height();
colorful = $("#colorful").attr("checked");
var container = $("<div />",{"id":"bokeh_container","style":"width:100%; height:100%; position:absolute; left:50%; margin-left:-600px; top:0px; z-index:1; display:none; "});
for( var i=0;i<bokeh_count;i++){
$("<div />",{"class":"bokeh","style":get_bokeh()}).appendTo(container);
}
container.appendTo("body").show();