Skip to content

Commit

Permalink
perf: load model-viewer library only when correct size
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz committed Jan 28, 2024
1 parent e288ea0 commit 118f100
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions resources/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ createInertiaApp({
})

window.requestIdleCallback(() => {
if (!window.matchMedia('(min-width: 768px)').matches) {
return
}

const scriptEl = document.createElement('script')
scriptEl.src = 'https://ajax.googleapis.com/ajax/libs/model-viewer/3.3.0/model-viewer.min.js'
scriptEl.async = true
Expand Down
4 changes: 0 additions & 4 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ body .v-popper--theme-tooltip .v-popper__arrow-outer {
@apply border-base4 backdrop-blur;
}

model-viewer {
height: 440px;
}

model-viewer[data-not-loaded] {
@apply hidden;
}
1 change: 0 additions & 1 deletion resources/views/app_root.edge
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">

<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.3.0/model-viewer.min.js" defer></script>
@vite(['resources/app.ts'])
</head>

Expand Down

0 comments on commit 118f100

Please sign in to comment.