Commit c0b48c8
committed
perf: move analytics scripts out of <head> to end of <body>
Google Analytics (gtag) and SimpleAnalytics scripts both relocate from <head> to just before </body>. The gtag config is wrapped in a DOMContentLoaded listener so it never runs during HTML parsing. Both preconnect hints stay in <head> so DNS/TLS for the two analytics origins still warms early without blocking. Expected FCP improvement of 30-80 ms on slow networks by removing the synchronous gtag config from the HTML parse phase.1 parent d681e44 commit c0b48c8
1 file changed
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | 4 | | |
13 | 5 | | |
14 | 6 | | |
| |||
136 | 128 | | |
137 | 129 | | |
138 | 130 | | |
139 | | - | |
| 131 | + | |
140 | 132 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 133 | + | |
146 | 134 | | |
147 | 135 | | |
148 | 136 | | |
| |||
158 | 146 | | |
159 | 147 | | |
160 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
0 commit comments