作法一:綁定真實載入進度(Vue 或 React,Pro)
傳入 0–100 的 progress 屬性即可讓粒子恰好於載入達 100% 時完全成形:
import { PixelLogoLoader } from './components/PixelLogoLoader';
<PixelLogoLoader progress={progress} height={360} />
作法二:以免費 HTML 匯出作為遮罩覆蓋層
將免費 index.html 上傳後置於 <body> 開頭,待 load 事件完成後移除:
<div id="logo-loader" style="position:fixed;inset:0;z-index:9999;background:#000;display:grid;place-items:center">
<iframe src="/particle-logo/index.html" title="Loading" width="480" height="520" style="border:0;max-width:100%"></iframe>
</div>
<script>
const loader = document.getElementById('logo-loader');
const shownAt = performance.now();
const MIN_MS = 1500; // 動畫至少顯示 1.5 秒
function hide() {
setTimeout(() => loader.remove(), Math.max(0, MIN_MS - (performance.now() - shownAt)));
}
if (document.readyState === 'complete') hide();
else window.addEventListener('load', hide);
</script>
尊重減少動態偏好
Vue / React 可傳入固定 progress=100,覆蓋層則可視偏好直接略過渲染。
訪客需下載多大的檔案?
於 2026 年 11 月 3 日 實測結果如下(預設步長 4,括號內為 gzip 後大小):
| 測試圖 | 取樣點數 | HTML 檔案 | Vue 元件 | React 元件 |
|---|---|---|---|---|
| 白色四字母字標(單色) | 589 | 22.4 KB (6.4 KB gzip) | 24.2 KB (6.9 KB gzip) | 25.1 KB (7.0 KB gzip) |
| 五種顏色的幾何圖形 | 4,139 | 66.5 KB (12.3 KB gzip) | 68.2 KB (12.9 KB gzip) | 69.2 KB (13.1 KB gzip) |
| Particle Logo 自家標誌(銀灰單色調) | 7,082 | 35.8 KB (11.0 KB gzip) | 37.5 KB (11.6 KB gzip) | 38.4 KB (11.7 KB gzip) |
檔案自包含點陣與程式碼(最多 1,600 個點),不發送額外網路請求。詳見價格頁。