[WordPress] 外掛分享: Lazy Load Fix for Divi

前言介紹

  • 這款 WordPress 外掛「Lazy Load Fix for Divi」是 2025-01-10 上架。
  • 目前有 40 個安裝啟用數。
  • 上一次更新是 2025-12-20,距離現在已有 67 天。
  • 外掛最低要求 WordPress 5.7.0 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.0 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

jerrystewart99 |

外掛標籤

divi | lazy | image | lazy load | above-the-fold |

內容簡介

**總結:**
- 該外掛提供細緻的控制,手動設置 Divi 頁面上需要進行懶加載的圖片的閾值。
- 包含一個修復 Divi 錯誤的功能,該錯誤導致懶加載閾值的計算不正確。

**問題與答案:**
1. 這個外掛的目的是什麼?
- 該外掛的目的是提供開發人員手動設置頁面上需要進行懶加載的圖片的閾值,以改進頁面加載性能。

2. 以下折疊 (btf) 媒體應該如何進行懶加載?
- 為了實現最佳頁面加載性能,只有 Below The Fold (btf) 媒體應該進行懶加載。這表示在第一次頁面加載之前不可見的部分應該延遲加載。

3. 如何使用 Lazy-Load-Fix-for-Divi 外掛來確定頁面上的第一個 btf 模塊?
- 您需要在設計頁面後,使用特定解析度的瀏覽器檢視您的頁面,識別第一個被認為是 btf 的 Divi 模塊。然後,手動設置閾值,並添加自定義類到第一個 btf 模塊中。

4. 這個外掛如何處理 Divi 的錯誤和 bug?
- 除了提供手動設置閾值外,這個外掛還修復了 Divi 相關懶加載圖片的錯誤。該錯誤是由於 Divi 的實際計算錯誤造成的,這個外掛安靜地修復了這個問題。

原文外掛簡介

Offers Fine-grained control for manually setting the threshold which images on a Divi page are lazy-loaded.
Includes a fix for a Divi bug that causes incorrect calculation of the lazy-load threshold.
Background
To improve page load performance, modern browsers allow for images and other media to be lazy loaded. Lazy loading defers media loading until after the first page render.
For best page load performance, only Below The Fold (btf) media should be lazy loaded. Below The Fold means the part of the page that is not visible on first page load, prior to any scrolling.
Google Page Speed Insights (PSI) will rightly complain if media atf are lazy loaded, and also if media btf are not lazy loaded.
In version 5.7.0, WordPress added a feature that automatically adds the loading=”lazy” attribute to media it considers to be btf. What it considers btf basically means everything after the 3rd media component irrespective of page design.
Divi’s Critical CSS feature attempts to do a better job of determining the fold by analysing the raw page modules’ shortcodes.
Divi offers different threshold settings of where it considers The Fold to be. eg. ‘Low’, ‘Medium’ or ‘High’. (This setting is found in Divi Settings|Performance|Critical CSS Threshold.)
The exact position of The Fold however, depends on a few factors, perhaps the most obvious is the screen width. Divi’s analysis is approximate and is easily confused by the use of additional custom css.
How the Lazy-Load-Fix-for-Divi plugin works
This plugin allows the developer to determine the exact position of The Fold by manually setting it’s location for each page. You can do this after making a simple observation in a browser at the screen widths you want to optimise for.
For example, suppose you decide that you want to optimise for the following screen resolutions:
1200 x 834 - desktop
320 x 820 - mobile

(these are the approximate resolutions that Google PSI uses)
Then, after completing your page design, inspect your page in a browser that is set to these dimensions(note 1) and identify the first Divi module that is btf.
To manually set the threshold, add one or more of the custom classes to the first Divi module btf.(note 2).
Allowed values are:
ww-btf-desktop
ww-btf-mobile
ww-btf-tablet (see note 3)

All media items btf will be lazy-loaded, those atf won’t be.
Repeat in the same way to set up thresholds for each page you want to optimise for.

Note that ww-btf-tablet is not implemented in this version and will be treated as ww-btf-mobile

Notes
Note 1 — Set a browser to a specific resolution I suggest using Chrome with Developer Tools enabled (right click, select Inspect). Resizing the window with a mouse shows the window size next to the cursor.
Note 2 — Add a custom class to a Divi module Edit the module and select the Advanced tab and use CSS ID & Classes
Note 3 — Tablet devices are not implemented in this plugin version and will be treated as if they were ww-btf-mobile
Divi BUG
In addition, this plugin fixes a code bug in Divi relating to the lazy loading of images. (introduced in 4.5.2 and still present in 4.27.4)
The problem occurs in
Divi\includes\builder\core.php @ line #63

– the remove_filter() call quietly fails because the priority is not specified. This bug results in the WordPress media counting logic to be run twice which defeats the lazy-load threshold when using Divi.
The WordPress function remove_filter() specifies parameter 3 as int $priority = 10. If the priority is not 10 (in this case it is actually 12), the remove_filter call fails.
I guess Elegant Themes’s priority are now with version 5 so this bug may not ever get fixed. If the bug ever gets fixed, this bugfix part of this plugin will have no effect.
This bugfix is distinct from and will work independently from the custom setting of the custom classes described above.
Note: I contacted Elegant Themes about the bug and was advised to use the plugin: “Disable Lazy Loading”
which does an excellent job of disabling ALL lazy loading.
In this case though, this is not the behaviour I want.
My motivation for writing this plugin is to improve the Google PSI score on Mobile and Desktop devices.
I welcome helpful comments and suggestions 🙂
This plugin will have no effect if used on Divi < 4.5 or on WordPress < 5.7.0

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Lazy Load Fix for Divi」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.1.0 | 1.1.1 | trunk |

延伸相關外掛(你可能也想知道)

  • Autoptimize criticalcss.com power-up 》此外掛將 Autoptimize 擴充,以自動創建臨界 CSS 樣式規則。這些規則會將正確的臨界 CSS 寫入不同類型的頁面中,以確保在載入完整 CSS 之前即可顯示這些頁面...。
  • ShortPixel Critical CSS 》使用 ShortPixel Critical CSS 外掛程式,您的網站能自動產生 「網頁視窗外CSS」 ,使網站加載速度加快,且測試工具 PageSpeed Insights 或 GTmetrix 能給出...。
  • WP Critical CSS 》這個外掛會自動向 CriticalCSS.com 網站服務取得每個網站頁面所需的重要 CSS,以幫助改善使用者體驗和網站速度。這通常是 Google Pagespeed 推薦完成的最後一...。
  • Smart Image Loader 》Smart Image Loader 只會載入在網站初始視窗中可見的圖片,在任何位置 “Below the Fold”(超出目前視窗範圍)的圖片之前。這些圖片可以在可見圖...。
  • Inline JS Block for Gutenberg 》行內 JS 區塊可協助添加置於畫面上方的 JS,或滿足您的進階個人化需求。, 注意:必須添加 JS Script 標籤以執行 JS 代碼,請務必加入這些標籤以編譯您的代碼。。
  • Inline CSS Block for Gutenberg 》內嵌 CSS 區塊可以幫助您添加以上折疊區的 CSS 或滿足進階自定義需求。。
  • jQuery & Plugins Asynchronous Loader 》載入 JavaScript 資源時應該以非同步、非阻塞的方式進行,以使您的網頁載入時間不受影響 (而不會被渲染阻塞的 JavaScript 延遲)。但使用延遲載入或非同步載入...。

文章
Filter
Mastodon