On Tue, Aug 28, 2012 at 12:57 AM, Tim Starling <tstarl...@wikimedia.org>wrote:

> Personally, I would use document.getElementById() to do that. It's
> standard, and it's faster and more secure.
>

I think your premature optimization disorder (POD) is flaring up again.
jQuery performance is something that should be understood but not obsessed
about. Is the code running in a tight loop? Is there
a perceivable performance problem? No? Move on please.

$( '<div>' ) or $( '<div />' ) ?

I think it's fine to choose one for consistency, but both are equally
performant[1]. and $( '<div>' ) has the benefit of being more brief.

Creating an element with attributes can be done like:

$( '<div>', { 'class', 'example' } );

It's important to note however that IE required that input and button tags
are created with a type (if they are going to have a specific one)

$( '<input type="password">', { 'class', 'example' } );

- Trevor

[1] http://en.wiktionary.org/wiki/performant
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to