Commit 9109ed3
committed
chore(activityCatalog): optimize page size
This PR refactors the data loading of the activity catalog to optimize
its page size. Currently, the activity catalog is 3mb uncompressed
(431kb compressed) which severely degrades performance and incurs
bandwidth costs.
\## Background
The activity catalog uses a full-text search database called Orama. To
eliminate the need to fetch data asynchronously, the original
implementation serialized the Orama database to json on the server side
and passed back to the client which deserializes it. Additionally, the
server pre-rendered all 150+ activities and added it to the HTML
response. The net effect is that all activity renders, the serialized
database (which contains the same activities) were added to the payload.
\## Optimization
To optimize this, only the first 8 activities (the first two rows on the
largest screen size) will be serialized (instead of all 100+
activities). The client will be responsible for loading the database
asynchronously and populating the remaining activities. This
optimization effectively allows the perceived performance to be high by
pre-rendering only content above the fold. The remaining activities will
be rendered in asynchronously after the page has loaded.
\## Perforamnce Gains
In testing, the current page is approximately 3mb uncompresed and
431kb compressed. It has a lighthouse performance score of 58.
After these changes, the page size is 972kb uncompressed and 120kb
compressed (a 3x improvement). It has a lighthouse performance score of
72.1 parent 51df895 commit 9109ed3
File tree
5 files changed
+105
-81
lines changed- apps/marketing
- src
- app/[brand]/[locale]/activities/[activityType]
- components/contentful/activityCatalog
- __tests__
5 files changed
+105
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
Lines changed: 5 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
93 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 101 | | |
108 | 102 | | |
109 | 103 | | |
| |||
132 | 126 | | |
133 | 127 | | |
134 | 128 | | |
135 | | - | |
| 129 | + | |
136 | 130 | | |
137 | 131 | | |
138 | 132 | | |
| |||
144 | 138 | | |
145 | 139 | | |
146 | 140 | | |
147 | | - | |
| 141 | + | |
148 | 142 | | |
149 | 143 | | |
150 | 144 | | |
| |||
Lines changed: 87 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
59 | 136 | | |
60 | 137 | | |
61 | 138 | | |
| |||
72 | 149 | | |
73 | 150 | | |
74 | 151 | | |
75 | | - | |
| 152 | + | |
76 | 153 | | |
77 | 154 | | |
78 | 155 | | |
| |||
85 | 162 | | |
86 | 163 | | |
87 | 164 | | |
88 | | - | |
| 165 | + | |
89 | 166 | | |
90 | 167 | | |
91 | 168 | | |
| |||
101 | 178 | | |
102 | 179 | | |
103 | 180 | | |
104 | | - | |
| 181 | + | |
105 | 182 | | |
106 | 183 | | |
107 | 184 | | |
| |||
124 | 201 | | |
125 | 202 | | |
126 | 203 | | |
127 | | - | |
| 204 | + | |
128 | 205 | | |
129 | 206 | | |
130 | 207 | | |
| |||
145 | 222 | | |
146 | 223 | | |
147 | 224 | | |
148 | | - | |
| 225 | + | |
149 | 226 | | |
150 | 227 | | |
151 | 228 | | |
| |||
161 | 238 | | |
162 | 239 | | |
163 | 240 | | |
164 | | - | |
| 241 | + | |
165 | 242 | | |
166 | 243 | | |
167 | 244 | | |
| |||
173 | 250 | | |
174 | 251 | | |
175 | 252 | | |
176 | | - | |
| 253 | + | |
177 | 254 | | |
178 | 255 | | |
179 | 256 | | |
| |||
Lines changed: 12 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | | - | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | | - | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 46 | + | |
56 | 47 | | |
57 | 48 | | |
58 | 49 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 50 | + | |
| 51 | + | |
64 | 52 | | |
65 | 53 | | |
66 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1672 | 1672 | | |
1673 | 1673 | | |
1674 | 1674 | | |
1675 | | - | |
1676 | 1675 | | |
1677 | 1676 | | |
1678 | 1677 | | |
| |||
4696 | 4695 | | |
4697 | 4696 | | |
4698 | 4697 | | |
4699 | | - | |
4700 | | - | |
4701 | | - | |
4702 | | - | |
4703 | | - | |
4704 | | - | |
4705 | | - | |
4706 | 4698 | | |
4707 | 4699 | | |
4708 | 4700 | | |
| |||
6529 | 6521 | | |
6530 | 6522 | | |
6531 | 6523 | | |
6532 | | - | |
| 6524 | + | |
6533 | 6525 | | |
6534 | 6526 | | |
6535 | 6527 | | |
6536 | 6528 | | |
6537 | 6529 | | |
6538 | 6530 | | |
6539 | | - | |
6540 | | - | |
6541 | | - | |
6542 | | - | |
6543 | | - | |
6544 | | - | |
6545 | | - | |
6546 | | - | |
6547 | | - | |
6548 | | - | |
6549 | | - | |
6550 | | - | |
6551 | 6531 | | |
6552 | 6532 | | |
6553 | 6533 | | |
| |||
12653 | 12633 | | |
12654 | 12634 | | |
12655 | 12635 | | |
12656 | | - | |
12657 | | - | |
12658 | | - | |
12659 | | - | |
12660 | | - | |
12661 | | - | |
12662 | | - | |
12663 | 12636 | | |
12664 | 12637 | | |
12665 | 12638 | | |
| |||
21599 | 21572 | | |
21600 | 21573 | | |
21601 | 21574 | | |
21602 | | - | |
21603 | | - | |
21604 | | - | |
21605 | | - | |
21606 | | - | |
21607 | | - | |
21608 | | - | |
21609 | 21575 | | |
21610 | 21576 | | |
21611 | 21577 | | |
| |||
0 commit comments