正式環境兩個頁面響應時間過長,Network 面板顯示 jquery.min.js 加載耗時數秒(甚至 10s+),文件已壓縮但仍未解決。
Cache-Control、ETag,或用戶強制刷新。<!-- 推薦:BootCDN (國內極快) -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!-- 備選:cdnjs (全球) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!-- 備選:Google CDN (海外) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!-- 關鍵:添加 integrity + crossorigin 開啟 SRI 防篡改 -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"
integrity="sha384-xxx"
crossorigin="anonymous"></script>
gzip on; gzip_types application/javascript;,體積減 70%+;location ~* \.js$ { expires 1y; add_header Cache-Control "public, immutable"; };<script src="..." defer></script> 或 async,不阻塞渲染。$(document).ready() 內做重計算,改用事件委托、IntersectionObserver;Cash (6KB)、Zepto、原生 fetch + querySelector。jquery.min.js 的 TTFB、Content Download、Total Time;Load、DOMContentLoaded、FCP、LCP 指標;WebPageTest、Lighthouse 多地點多瀏覽器回歸。接入成熟公共 CDN(BootCDN/cdnjs)是解決 jQuery 加載慢的「銀彈」:零代碼改動、零成本、即時生效、全球加速。輔以 Gzip、強緩存、HTTP/2、異步加載等工程化手段,可將靜態資源加載時間壓縮至 50ms 以內,徹底消除「因 jQuery 拖慢首屏」的性能瓶頸。