Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • If you have a reasonably or entirely fixed template, use something like HandlebarsJS to make a template that you populate.

  • Now about performance, I would suggest you make a jsPerf test for your specific case and try out the different options to see which is fastest since the right answer is really different for each case. Here's an interesting answer to a question about passing HTML strings: http://stackoverflow.com/questions/3015335/jquery-html-vs-append

  • A big no no for me is putting an append in a loop. It's going to be much better if you do a loop and cache the things to append into a variable, then do a single append with that. DOM manipulations carry some of the highest costs to performance. If you check out this article you can see the tests with arrays and performance costs first hand: http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly

  • If you have a reasonably or entirely fixed template, use something like HandlebarsJS to make a template that you populate.

  • Now about performance, I would suggest you make a jsPerf test for your specific case and try out the different options to see which is fastest since the right answer is really different for each case. Here's an interesting answer to a question about passing HTML strings: https://stackoverflow.com/questions/3015335/jquery-html-vs-append

  • A big no no for me is putting an append in a loop. It's going to be much better if you do a loop and cache the things to append into a variable, then do a single append with that. DOM manipulations carry some of the highest costs to performance. If you check out this article you can see the tests with arrays and performance costs first hand: http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly

Source Link
Jonny Sooter
  • 1.4k
  • 12
  • 33
  • If you have a reasonably or entirely fixed template, use something like HandlebarsJS to make a template that you populate.

  • Now about performance, I would suggest you make a jsPerf test for your specific case and try out the different options to see which is fastest since the right answer is really different for each case. Here's an interesting answer to a question about passing HTML strings: http://stackoverflow.com/questions/3015335/jquery-html-vs-append

  • A big no no for me is putting an append in a loop. It's going to be much better if you do a loop and cache the things to append into a variable, then do a single append with that. DOM manipulations carry some of the highest costs to performance. If you check out this article you can see the tests with arrays and performance costs first hand: http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly

default

AltStyle によって変換されたページ (->オリジナル) /