Skip to content

Commit 27a990f

Browse files
authored
Optimize JS (#1528)
* Remove unused cshtml template * Move main js to head with `defer` * Split web components into its own file * Add bundle analyzer
1 parent 671dcde commit 27a990f

File tree

7 files changed

+28
-25
lines changed

7 files changed

+28
-25
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './web-components/VersionDropdown'

src/Elastic.Documentation.Site/Assets/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { initNav } from './pages-nav'
77
import { initSmoothScroll } from './smooth-scroll'
88
import { initTabs } from './tabs'
99
import { initTocNav } from './toc-nav'
10-
import './web-components/VersionDropdown'
1110
import 'htmx-ext-head-support'
1211
import 'htmx-ext-preload'
1312
import 'htmx.org'

src/Elastic.Documentation.Site/Layout/_Footer.cshtml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@inherits RazorSlice<Elastic.Documentation.Site.GlobalLayoutViewModel>
22

3-
43
<footer class="py-12 px-6 w-full mx-auto bg-ink-dark">
54
<div class="max-w-(--max-layout-width) w-full mx-auto">
65
<div class="text-grey-20 text-[12px]">
@@ -34,5 +33,3 @@
3433
</div>
3534
</div>
3635
</footer>
37-
38-
<script src="@Model.Static("main.js")"></script>

src/Elastic.Documentation.Site/Layout/_Head.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<link rel="preload" href="@fontFile" as="font" type="font/woff2" crossorigin>
99
}
1010
<link rel="stylesheet preload" as="style" type="text/css" href="@Model.Static("styles.css")" crossorigin/>
11+
<script src="@Model.Static("custom-elements.js")" defer></script>
12+
<script src="@Model.Static("main.js")" defer></script>
1113
@if (Model.CanonicalBaseUrl is not null)
1214
{
1315
<link rel="canonical" href="@Model.CanonicalUrl" />

src/Elastic.Documentation.Site/Layout/_Scripts.cshtml

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

src/Elastic.Documentation.Site/package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Elastic.Documentation.Site/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"fmt:write": "prettier --write ."
1313
},
1414
"targets": {
15+
"customElements": {
16+
"distDir": "_static",
17+
"source": "Assets/custom-elements.ts"
18+
},
1519
"js": {
1620
"distDir": "_static",
1721
"source": "Assets/main.ts"
@@ -33,6 +37,7 @@
3337
"@emotion/css": "11.13.5",
3438
"@emotion/react": "11.14.0",
3539
"@eslint/js": "9.30.1",
40+
"@parcel/reporter-bundle-analyzer": "2.15.4",
3641
"@r2wc/react-to-web-component": "2.0.4",
3742
"@tailwindcss/postcss": "4.1.11",
3843
"@trivago/prettier-plugin-sort-imports": "5.2.2",

0 commit comments

Comments
 (0)