wolfceo

wolfceo

Magento2 前端性能優化建議

對於希望提高 Adobe Commerce 商店前端速度和優化前端性能的人來說,以下是一些很好的起點,重點是 Lighthouse 分數:

  1. 合併 CSS => https://experienceleague.adobe.com/docs/commerce-admin/config/advanced/developer.html
  2. 壓縮 CSS => https://experienceleague.adobe.com/docs/commerce-admin/config/advanced/developer.html
  3. 壓縮 JS => https://experienceleague.adobe.com/docs/commerce-admin/config/advanced/developer.html
  4. 將 JS 移至頁面底部 => https://experienceleague.adobe.com/docs/commerce-admin/config/advanced/developer.html
  5. 啟用 Critical CSS => https://developer.adobe.com/commerce/frontend-core/guide/css/critical-path
  6. 為每個頁面創建獨特的 Critical CSS => https://github.com/Joshua34/CriticalCSSPerPage
  7. 將資源添加到 CSP 白名單 => https://developer.adobe.com/commerce/php/development/security/content-security-policies/#configure-csps-for-your-custom-codeextensiontheme
  8. 懶加載所有在頁面下方的圖片 => https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading#images_and_iframes
  9. 對 LCP 元素添加fetchpriority="high" => https://web.dev/priority-hints/
  10. 對於 LCP 和所有 Critical 資源,添加<link rel="preload"> => https://web.dev/preload-critical-assets/
  11. 對於任何外部 Critical 資源,添加<link rel="preconnect"> => https://developer.chrome.com/en/docs/lighthouse/performance/uses-rel-preconnect/
  12. 根據需要,排除任何關鍵腳本的移動 => https://magento.stackexchange.com/a/363633/5880
  13. 安裝、生成、打包並啟用 MagePack => https://github.com/magesuite/magepack
  14. 對於所有生成的 magepack 文件,在<head>中添加<link rel="preload">
  15. 減少未使用的 CSS => https://developer.chrome.com/en/docs/lighthouse/performance/unused-css-rules/
  16. 只選擇需要運行的腳本和 GTM 標籤
  17. 確保所有腳本和外部資源都使用最新版本
  18. 過濾加載的字體庫,刪除未使用的字形 => https://web.dev/font-best-practices/
  19. 對於所有外部字體,在<head>中添加<link rel="preload"> => https://web.dev/optimize-webfont-loading/
  20. 安裝並配置 varnish => https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/cache/varnish/config-varnish.html
  21. 將緩存資源提供給訪問者 => https://developer.chrome.com/en/docs/lighthouse/performance/uses-long-cache-ttl/
  22. 如果使用 cloudflare,啟用 webp 支援 => https://developers.cloudflare.com/images/polish/activate-polish
  23. 對於所有資源,使用 http/2 傳遞 => https://www.cloudflare.com/learning/performance/http2-vs-http1.1/
  24. 在生產模式下運行 Magento => https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/setup/application-modes.html
  25. 清理網站數據庫
  26. 刪除所有未使用的第三方模塊、腳本和字體
  27. 檢查代碼中是否存在重複調用資源、腳本、字體和樣式規則
  28. 修復所有控制台錯誤
  29. 修復所有 HTML 代碼錯誤 => https://validator.w3.org/
  30. 在瀏覽器閒置後,對預期的資源添加<link rel="prefetch"> => https://web.dev/link-prefetch/
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。