perf: add preload and content-visibility attribute to media preview for improved performance (#10806)

## Summary

this pull request is to improve the performance of large workflows
containing numerous Media Previews.

Added content-visibility: auto, which enables the browser to lazily
render Media Previews outside the viewport.

Added preload="metadata", which makes <video> and <audio> elements only
preload metadata instead of the full content.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10806-perf-add-preload-and-content-visibility-attribute-to-media-preview-for-improved-perfor-3356d73d365081238ce8f1a82f8694ec)
by [Unito](https://www.unito.io)
This commit is contained in:
Rizumu Ayaka
2026-04-09 05:08:47 +08:00
committed by GitHub
parent 537e4bc4f2
commit 44c3d08b56
3 changed files with 6 additions and 1 deletions

View File

@@ -46,6 +46,7 @@
v-if="!videoError"
:src="currentVideoUrl"
:class="cn('block size-full object-contain', showLoader && 'invisible')"
preload="metadata"
controls
loop
playsinline

View File

@@ -5,6 +5,7 @@
:key="index"
:src="url"
controls
preload="metadata"
class="w-full"
/>
</div>

View File

@@ -2,7 +2,10 @@
<div v-if="renderError" class="node-error p-2 text-sm text-red-500">
{{ st('nodeErrors.content', 'Node Content Error') }}
</div>
<div v-else class="lg-node-content flex flex-auto grow flex-col">
<div
v-else
class="lg-node-content flex flex-auto grow flex-col [content-visibility:auto]"
>
<!-- Default slot for custom content -->
<slot>
<VideoPreview