Skip to content

Commit b4ec437

Browse files
committed
Speed up rendering for very large data
It does this by not rendering properties that aren't opened. It works best when the data is chunked. The test data has 100 chunks with 100 items each. Without this change, it would take 2000ms to render all 10000 properties. With this change, properties are re-rendered when clicked, which takes 30-50ms, which is a huge improvement. It's not perfect, but it's a huge improvement for viewing large amounts of data with heavily nested properties.
1 parent 76a6770 commit b4ec437

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

dev/serve.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
import { defineComponent } from 'vue';
3333
import JsonView from '@/JsonView.vue';
3434
35+
// large chunked data, takes 2s to render all at once.
36+
const largedata: any = {};
37+
for (let i = 0; i < 100; i++) {
38+
const chunk: any = largedata[i] = []
39+
for (let j = 0; j < 100; j++) {
40+
chunk.push(j);
41+
}
42+
}
43+
3544
export default defineComponent({
3645
name : 'ServeDev',
3746
components: { JsonView },
@@ -64,7 +73,8 @@
6473
],
6574
object : {
6675
working: 'properly'
67-
}
76+
},
77+
largedata
6878
};
6979
},
7080
colorScheme(): string {

src/JsonViewItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
v-for="child in data.children"
1717
:key="getKey(child)"
1818
:data="child"
19-
v-show="open"
19+
v-if="open"
2020
:maxDepth="maxDepth"
2121
:canSelect="canSelect"
2222
/>

0 commit comments

Comments
 (0)