Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:37:30+00:00 2026-06-08T21:37:30+00:00

I’m trying to create a simple markup with templates. Something like: <div class=list data-bind=template:

  • 0

I’m trying to create a simple markup with templates. Something like:

<div class="list" data-bind="template: {name: 'mytemplate', data: someData}"></div>

<script id="mytemplate">
  <div class="item" data-bind="text: someText"></div>
</script>

It works very nice, but if i need to render a lot of divs with this templates its going to be very slow. Knockout after creating each div adds it to the document. But, if i do something like this:

el = document.createElement("div");
applyBindings(myModel, el);

(div.list).innerHTML = el.innerHTML

It works much faster but is inconvenient.

Maybe Knockout has some built in feature for creating a group of element and after that adding this group to the document?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:37:32+00:00Added an answer on June 8, 2026 at 9:37 pm

    It sounds like KO is manipulating the DOM with each DIV you add. DOM traversal is expensive and will slow down the rendering of your page. There is an open issue for this under the KO Github: https://github.com/SteveSanderson/knockout/issues/248

    In my opinion, Knockout is presently not up to the task of handling large foreach data sets. Performance on Chrome is decent (because Chrome is awesome), but pretty bad on Internet Explorer (and even worse on older IE): http://jsfiddle.net/StarcounterJack/FgSCw/

    Instead of using Knockout, try a manual approach: create the DIVs in memory first and insert them into the DOM all at once. This is what you’re doing in your second example with document.createElement(). With jQuery, you could do this:

    var newDiv = $("<div>my new div</div>");
    var newDiv2 = $("<div>my new div2</div>");
    newDiv.append(newDiv2);
    $('body').append(newDiv); //only this last step traverses the DOM
    

    For templating, I prefer to use Mustache.js, load the templates using John Resig’s <head><script type="text/templates"> template inclusion trick and take care of the rendering manually through my own JavaScript. You have more control over how the elements are rendered and can try different approaches when you run into performance problems like the one you have now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.