-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
181 lines (165 loc) · 5.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!doctype html>
<html lang=en>
<head>
<meta name=viewport content=width=device-width>
<title>React v. Lit</title>
<link rel=stylesheet href=./node_modules/@vanillawc/wc-codemirror/theme/monokai.css>
<style>
main table { width: 100% }
th, td { text-align: left; vertical-align: top }
.CodeMirror { height: auto !important }
#gh-logo { height: 32px; width: 32px; padding: 6px }
</style>
<script type=module src=./lib/index.js></script>
</head>
<body>
<h1>React v. Lit</h1>
<p>Compares React and Lit implementations of the React homepage demos.</p>
<p>The React side uses <a href=https://www.pika.dev/search?q=reactesm>React ESM</a> and <a href=https://pkg.fyi/npm:htm>HTM</a>. These tweaks eliminate the need for a build step. You can run the <a href=https://reactjs.org target=_blank>standard React demos</a> in another tab to compare further.</p>
<p><a href=https://lit-element.polymer-project.org/>LitElement</a> is used for most demos on the Lit side with the exception of Introducing Hooks which brings in <a href=https://pkg.fyi/npm:haunted>Haunted</a>.</p>
<p>Worth noting is the use of install-time ESM-enabling technology, <a href=https://www.snowpack.dev>Snowpack</a>.</p>
<table>
<tr><th></th><th>Size (GZIPPED, MINIFIED)</th></tr>
<tr><th>React ESM + HTM</th><td>38 KB + 0.6 KB</td></tr>
<tr><th>LitElement</th><td>6.9 KB</td></tr>
<tr><th>Haunted</th><td>5.6 KB</td></tr>
</table>
<main>
<section>
<h2>A Simple Component</h2>
<table>
<tr><th>React</th><th>Lit</th></tr>
<tr>
<td>
<wc-codemirror src=./lib/react-simple.js mode=javascript theme=monokai></wc-codemirror>
</td>
<td>
<wc-codemirror src=./lib/lit-simple.js mode=javascript theme=monokai></wc-codemirror>
</td>
</tr>
<tr>
<td>
<fieldset><legend>Output</legend>
<div id=hello-example></div>
</fieldset>
</td>
<td>
<fieldset><legend>Output</legend>
<hello-example name=Taylor></hello-example>
</fieldset>
</td>
</tr>
</table>
</section>
<section>
<h2>A Stateful Component</h2>
<table>
<tr><th>React</th><th>Lit</th></tr>
<tr>
<td>
<wc-codemirror src=./lib/react-stateful.js mode=javascript theme=monokai></wc-codemirror>
</td>
<td>
<wc-codemirror src=./lib/lit-stateful.js mode=javascript theme=monokai></wc-codemirror>
</td>
</tr>
<tr>
<td>
<fieldset><legend>Output</legend>
<div id=timer-example></div>
</fieldset>
</td>
<td>
<fieldset><legend>Output</legend>
<timer-example></timer-example>
</fieldset>
</td>
</tr>
</table>
</section>
<section>
<h2>An Application</h2>
<table>
<tr><th>React</th><th>Lit</th></tr>
<tr>
<td>
<wc-codemirror src=./lib/react-app.js mode=javascript theme=monokai></wc-codemirror>
</td>
<td>
<wc-codemirror src=./lib/lit-app.js mode=javascript theme=monokai></wc-codemirror>
</td>
</tr>
<tr>
<td>
<fieldset><legend>Output</legend>
<div id=todos-example></div>
</fieldset>
</td>
<td>
<fieldset><legend>Output</legend>
<todos-example></todos-example>
</fieldset>
</td>
</tr>
</table>
</section>
<section>
<h2>A Component Using External Plugins</h2>
<table>
<tr><th>React</th><th>Lit</th></tr>
<tr>
<td>
<wc-codemirror src=./lib/react-external.js mode=javascript theme=monokai></wc-codemirror>
</td>
<td>
<wc-codemirror src=./lib/lit-external.js mode=javascript theme=monokai></wc-codemirror>
</td>
</tr>
<tr>
<td>
<fieldset><legend>Output</legend>
<div id=markdown-example></div>
</fieldset>
</td>
<td>
<fieldset><legend>Output</legend>
<markdown-example></markdown-example>
</fieldset>
</td>
</tr>
</table>
</section>
<section>
<h2>Introducing Hooks</h2>
<table>
<tr><th>React</th><th>Lit</th></tr>
<tr>
<td>
<wc-codemirror src=./lib/react-hooks.js mode=javascript theme=monokai></wc-codemirror>
</td>
<td>
<wc-codemirror src=./lib/lit-hooks.js mode=javascript theme=monokai></wc-codemirror>
</td>
</tr>
<tr>
<td>
<fieldset><legend>Output</legend>
<div id=hooks-example></div>
</fieldset>
</td>
<td>
<fieldset><legend>Output</legend>
<hooks-example></hooks-example>
</fieldset>
</td>
</tr>
</table>
</section>
</main>
<footer>
<a href=https://github.com/pinkhominid/react-v-lit>
<img id=gh-logo alt=GitHub src=./github.svg>
</a>
</footer>
</body>
</html>