Сүрөттөө
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 asww-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.0)
The problem occurs in
Divi\includes\builder\core.php @ line #63
– the remove_filter() call quietly fails because the priority is not specified, resulting in the WordPress media counting logic to be run twice. This stuffs up the lazy-load threshold within WordPress.
This plugin quietly fixes the problem. If ET ever fixes this bug this section of the 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
Скриншоттор
Орнотуу
Lazy Load Fix For Divi just as you would any other WP Plugin:
-
Download Lazy Load For Divi from WordPress.org.
-
Unzip the .zip file.
-
Upload the Plugin folder (lazy-load-fix-for-divi/) to the wp-content/plugins folder.
-
Go to Plugins Admin Panel and find the newly uploaded Plugin, “Lazy Load Fix for Divi” in the list.
-
Click Activate Plugin to activate it.
FAQ.KG
-
Will this Plugin work on my WordPress.com website?
-
Sorry, this plugin is available for use only on self-hosted (WordPress.org) websites.
-
Can I use this plugin with the Divi Builder
-
This plugin has only been tested with the Divi Theme to date. It may work with Divi Builder using a different theme. Please do let me know how that goes 🙂
-
What Divi settings should I use
-
This is a performance tweak plugin. It is only effective if Divi’s performance options are ENABLED, and in particular Critical CSS must be ENABLED for this plugin to have any effect. (This is the Divi default)
-
Will this work on Divi 5?
-
No. Divi 4 only please.
-
How do I use this plugin?
-
Install and activate. Add custom classes as per description. That’s it!
-
How to uninstall the plugin?
-
Simply deactivate and delete the plugin. It will clean up nicely and leave no trace.
Сын-пикирлер
There are no reviews for this plugin.
Contributors & Developers
“Lazy Load Fix for Divi” is open source software. The following people have contributed to this plugin.
МүчөлөрүTranslate “Lazy Load Fix for Divi” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Өзгөртүүлөр
1.1
Added ability to set The Fold per page, per device
1.0
Inital Release – Divi bugfix only