The following link is a code snippet in PasteBin that shows the methods and a quick test:
Basically, the two I wrote and that I’m evaluating are:
- Create Element
- This method caches a created element instance in an array. In some browsers, like Firefox, this method is marginally faster; I’m thinking the array access is hindering it from being even faster.
- Create Element with Properties
- This method basically allows you to set attributes using a JSON object. Nothing fancy, but the developers like it. I’m concerned about the speed of the loop, and developers have been asking about how to set the runtime style. Since
element.styleis, of course, not settable, I’d have to either expose a second parameter, or allow a more complex object and write more logic, (assuming I decide to support it).
I’d love some advice… here’s what I don’t want:
Just use jQuery / Prototype / my framework!
That kind of defeats the purpose of this exercise!