I've noticed that the performance of my web apps is very slow when
dealing with large amounts of data (e.g. generating >100 tree nodes,
each of which includes InPlaceEditors, Tooltips (my own using
Prototype/SAU), lots of various nodes built with Builder.node, etc...).
I started using the new Firebug 1.0 beta's profiling and discovered a
few things.
1) Builder.node calls escapeHTML on all attribute values when parsing
the attributes
2) escapeHTML creates a div node and a text node each time it is called
3) The combination of 1) and 2) yields a massive performance hit
So what is the reason for 1)? I don't know of any *standard* attribute
values offhand that use special HTML characters, nor can I think of a
good reason to. I don't think it'd be too much to ask for the programmer
to realize when he may be using HTML characters and have the foresight
to add .escapeHTML to the string when it is passed. Maybe there is a
common case that makes this worth while that I don't know of?
------------For reference----------
_attributes: function(attributes) {
var attrs = [];
for(attribute in attributes)
attrs.push((attribute=='className' ? 'class' : attribute) +
'="' + attributes[attribute].toString().escapeHTML() + '"');
return attrs.join(" ");
},
-----------------------------------
On 2), why can't the escapeHTML function create a div node and a text
node once one the first call and reuse it on subsequent calls? Also, is
this not a leak?
------------For reference---------
escapeHTML: function() {
var div = document.createElement('div');
var text = document.createTextNode(this);
div.appendChild(text);
return div.innerHTML;
},
----------------------------------
Thoughts?
Thanks,
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---