Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#2648 closed defect (wontfix)

toCamelCase is slow on IE6

Reported by: guest Owned by: anonymous
Priority: high Milestone:
Component: General Version: 0.4.2
Keywords: Cc:
Blocked by: Blocking:


(from sdrye at, ATG CLA on file)

The toCamelCase function is slow on IE6, and can be improved for the other browsers, too.

Using Tito Web Studio to profile laying out our UI onresize, I noticed that toCamelCase was using 20+% of the time on IE6 (~7% on Firefox 2). Adding a simple cache to the function drastically sped it up, so it was only taking 7% of the time on IE6 (~2% on Firefox).

I think adding this cache is a good idea, since the set of selectors is not that large. It could even be pre-populated, but that would increase the download size so it might not be worth it.

Here's my patch (not in diff form, since it's pretty trivial):

dojo.html.toCamelCaseMap = {};
dojo.html.toCamelCase = function(/* string */selector){
	//	summary
	//	Translates a CSS selector string to a camel-cased one.
    if (dojo.html.toCamelCaseMap[selector]) return dojo.html.toCamelCaseMap[selector];
	var arr = selector.split('-'), cc = arr[0];
	for(var i = 1; i < arr.length; i++) {
		cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1);
	dojo.html.toCamelCaseMap[selector] = cc;
	return cc;	//	string

Change History (3)

comment:1 Changed 10 years ago by jburke

  • Milestone set to 0.4.3

Setting to 0.4.3, but feel free to override. I tried it out for one the apps I work on, and saw a 10% improvement during widget creation and init/resizing phase. Patch needs to be reworked for Dojo style, but seemed to be useful.

comment:2 Changed 10 years ago by peller

  • Resolution set to wontfix
  • Status changed from new to closed

We did away with toCamelCase for 0.9

comment:3 Changed 9 years ago by anonymous

  • Milestone 0.4.4 deleted

Milestone 0.4.4 deleted

Note: See TracTickets for help on using tickets.