HTML Preparation code:
x
 
1
<section class="cards"></section>
2
3
<template id="product-card-template">
4
    <div class="product-card">
5
        <img class="product-card__photo" src="#" alt="" />
6
        <div class="product-card__text-container">
7
            <h3 class="product-card__title"></h3>
8
            <p class="product-card__cost"></p>
9
        </div>
10
        <div class="product-card__button-container">
11
            <button class="product-card__order-button" type="button">Заказать</button>
12
            <button class="product-card__basket-button" type="button">В корзину</button>
13
        </div>
14
    </div>
15
</template>
Script Preparation code:
 
var sectionCards = document.querySelector('.cards');
var templateCards = document.querySelector('#product-card-template');
var cardInnerHTML = `<div class="product-card">
        <img class="product-card__photo" src="#" alt="" />
        <div class="product-card__text-container">
            <h3 class="product-card__title"></h3>
            <p class="product-card__cost"></p>
        </div>
        <div class="product-card__button-container">
            <button class="product-card__order-button" type="button">Заказать</button>
            <button class="product-card__basket-button" type="button">В корзину</button>
        </div>
    </div>`;
Tests:
  • Paste node template

     
    for (let index = 0; index < 10; index++) {
      var cardTemplate = templateCards.content.querySelector('.product-card').cloneNode(true);
      sectionCards.prepend(cardTemplate);
    }
  • Paste ready html

     
    var result;
    for (let index = 0; index < 10; index++) {
      result += cardInnerHTML
    }
    sectionCards.innerHTML = result;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Paste node template
    Paste ready html

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0
Firefox 108 on Windows
View result in a separate tab
Test name Executions per second
Paste node template 6120.8 Ops/sec
Paste ready html 4501.2 Ops/sec