I would definitely need to see proof of cloneNode being faster than
createElement before moving forward with something like this
(especially in IE).

Although, I'm a bit hesitant landing a change like this, wholesale -
mostly because we're looking at better templating solutions for after
1.4 and this seems hacky, at best.

--John



On Mon, Jan 4, 2010 at 7:50 AM, James Padolsey
<jamespadol...@googlemail.com> wrote:
> I've been looking into jQuery.fragments and have a couple of
> suggestions.
>
> It'd be useful, I think, if jQuery.fragments could be used to store
> basic DOM nodes as well, for example (currently it only stores
> fragments):
>
> jQuery.fragments['<div/>'] = document.createElement('div');
>
> ...
>
> cachedDiv.cloneNode(false); seems to be faster than
> document.createElement('div'). (I've only tested briefly in Chrome &
> FF)
>
> Anyway, currently, jQuery checks for simple HTML like "<div/>" and
> will create an element on the fly, without even checking
> jQuery.fragments for that element. Maybe these single DOM nodes could
> also be cached in jQuery.fragments, but on their own -- not within a
> fragment.
>
> Also, checking against jQuery.fragments for simple HTML ("<div/>")
> would open doors for built-in "templating" (minus the interpolation
> and all that jazz). E.g.
>
> jQuery.extend(jQuery.fragments, {
>    '<containerDiv/>': $('<div class="container">...</div>')[0] //
> or, .parent()[0] to get at fragment...
> });
>
> ... And later on:
>
> $('<containerDiv/>') ...
>
> Just an idea.
>
> I really like the idea of caching HTML, but I think the current
> behaviour could be extended to make it a little more useful.
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "jQuery Development" group.
> To post to this group, send email to jquery-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> jquery-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/jquery-dev?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to