Ticket #8109 (closed enhancement: invalid)
Meta: jQuery.tmpl Performance Issues
| Reported by: | rwaldron | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.next |
| Component: | templates | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by rwaldron) (diff)
Opening up discussion to document the improvement of jQuery.tmpl performance, as illustrated here:
Change History
comment:1 Changed 2 years ago by rwaldron
- Priority changed from undecided to high
- Component changed from unfiled to templates
- Description modified (diff)
comment:4 Changed 2 years ago by BorisMoore
Perf is important, but perf comparisons are sometimes incorrect. The tests on the link are comparing how long each engine takes to render an HTML string. But for jQuery templates, they are using calling $.tmpl(template, data)- many times, which does not render an HTML string. It builds a jQuery object around a document fragment containing the rendered HTML ready for chaining with .appendTo. To use this without calling appendTo makes no sense, and will not perform well. It does much more than build an HTML string.
One of the goals of Beta2, planned for April, is to provide an API to allow you just to render an HTML string, if that is all you want. You can then innerHTML or .html(), for example to insert it. You can also render as a string on the server, and render that to the Response, for initial rendering. But there is also an activation step, which runs by default, and gives you tmplItem, and opens the way to all the interactive applications, if your app is not just read-only rendering. You can choose whether you want activation or not.
The current implementation uses a mix of string concatenation and document fragment instantiation, and does not provide an option for just rendering to a string. That has history going all the way back to the first prototype which John created, which this evolved from. See this issue, for related discussion: https://github.com/jquery/jquery-tmpl/issues/closed#issue/4. It links also to a discussion here: http://rileydutton.com/post/1303173205/jquery-templates-vs-jqote-2-a-followup-a-k-a-the%20%20
comment:5 Changed 2 years ago by BorisMoore
I have added a revision to the perf comparison benchmark here: http://jsperf.com/dom-vs-innerhtml-based-templating/83, to correct some errors in the tests. The result is the jQuery Templates come out 12 times faster than the previous (misleading) results. The results are better than some of the other template engines, but fall quite a lot short of the fastest ones. That said, jQuery Templates does much more than those other fastest ones, (which are basically stripped down to minimal features for read-only rendering, no detection of functions, undefined, etc., with perf being in most cases their primary goal, I believe.)
I think that the design changes in the pipeline for Beta2 will bring some signficant perf improvement for jQuery Templates, when used in read-only scenarios...
comment:6 Changed 2 years ago by john
- Status changed from open to closed
- Resolution set to invalid
This should be moved over to the jQuery Templates bug tracker.
comment:7 Changed 2 years ago by BorisMoore
Yes, this corresponds to https://github.com/jquery/jquery-tmpl/issues/4
comment:8 Changed 12 months ago by Jeffery To
- Resolution changed from invalid to fixed
Fix #8109, percent animations; fix #11854, wrong this, close gh-808
Changeset: 801768386b9fd44f1282834449b4cd1ae1e8d593
comment:9 Changed 12 months ago by dmethvin
- Status changed from closed to reopened
- Resolution fixed deleted
Ignore the message above, should have referenced #7109.
comment:10 Changed 12 months ago by dmethvin
- Status changed from reopened to closed
- Resolution set to invalid
This is not a jQuery Core ticket.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
