Skip to content

Commit 8668feb

Browse files
committed
New changes to improve create row performance
1 parent 3c7a6c4 commit 8668feb

File tree

3 files changed

+11
-92
lines changed

3 files changed

+11
-92
lines changed

frameworks/keyed/vanillajs-3/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ <h1>Vanillajs-3-"keyed"</h1>
7878
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
7979
</div>
8080
</div>
81-
<template id="itemTemplate"><tr><td class='col-md-1'>{id}</td><td class='col-md-4'><a class='lbl'>{lbl}</a></td><td class='col-md-1'><a class='remove'><span class='remove glyphicon glyphicon-remove' aria-hidden='true'></span></a></td><td class='col-md-6'></td></tr></template>
81+
<template id="t1000"><tr><td class='col-md-1'>{id}</td><td class='col-md-4'><a class='lbl'>{lbl}</a></td><td class='col-md-1'><a class='remove'><span class='remove glyphicon glyphicon-remove' aria-hidden='true'></span></a></td><td class='col-md-6'></td></tr></template>
82+
<template id="t10000"><tr><td class='col-md-1'>{id}</td><td class='col-md-4'><a class='lbl'>{lbl}</a></td><td class='col-md-1'><a class='remove'><span class='remove glyphicon glyphicon-remove' aria-hidden='true'></span></a></td><td class='col-md-6'></td></tr></template>
8283
<script src='src/Main.js'></script>
8384
</body>
8485
</html>

frameworks/keyed/vanillajs-3/index_backup.html

Lines changed: 0 additions & 84 deletions
This file was deleted.

frameworks/keyed/vanillajs-3/src/Main.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
(function() {
33
let index = 1, data = [], labels = null, invalidLabels = true, selected = null;
44
const tbody = document.getElementsByTagName('tbody')[0];
5-
5+
6+
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
7+
const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
8+
const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
9+
const l1 = adjectives.length, l2 = colours.length, l3 = nouns.length;
10+
const nts = (n) => Math.round(n / 100)
11+
612
function run(n = 1000) { if (data.length) clear(); add(n); }
713
function runlots() { run(10000) }
814
function add(n = 1000) {
9-
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
10-
const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
11-
const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
12-
const l1 = adjectives.length, l2 = colours.length, l3 = nouns.length;
13-
const nts = {1000: 5, 10000: 125}, nt = nts[n];
15+
const nt = nts(n);
1416
let i, j = 0, r1, r2, r3;;
1517

16-
const itemTemplates = document.getElementById('itemTemplate').content.cloneNode(true);
18+
const itemTemplates = document.getElementById(`t${n}`).content // .cloneNode(true);
1719
if (itemTemplates.children.length < nt) {
1820
const itemTemplate = itemTemplates.firstElementChild;
1921
while (nt >= itemTemplates.children.length * 2) itemTemplates.appendChild(itemTemplates.cloneNode(true));

0 commit comments

Comments
 (0)