Thread Starter
Anonymous User 14978628
(@anonymized-14978628)
Thanks Florian,
You might want to put that in the FAQ so it’s easier to find.
It would also be good having an option for this directly within the plugin itself.
Thread Starter
Anonymous User 14978628
(@anonymized-14978628)
After reading the github page (https://github.com/aFarkas/lazysizes#js-api—options) it says that the threshold is adjusted dynamically according to device and network activity.
Has this functionality been changed in your plugin?
I ask because that page said the default threshold is 370-500
But in the example you gave it appears to have been shortened?
function slug_enqueue_lazysizes_options() {
wp_add_inline_script( 'lazysizes', 'window.lazySizesConfig = window.lazySizesConfig || {}; lazySizesConfig.expand = 100;', 'before' );
}
add_action( 'wp_enqueue_scripts', 'slug_enqueue_lazysizes_options' );
I was going to set a value of 300, but i’m not sure now if this is necessary as the help page says the default is 370-500?
lazySizesConfig.expand (default: 370-500): The expand option expands the calculated visual viewport area in all directions, so that elements can be loaded before they become visible. The default value is calculated depending on the viewport size of the device. (Note: Reasonable values are between 300 and 1000 (depending on the expFactor option.) In case you have a lot of small images or you are using the LQIP pattern you can lower the value, in case you have larger images set it to a higher value. Also note, that lazySizes will dynamically shrink this value to 0 if the browser is currently downloading and expand it if the browser network is currently idling and the user not scrolling (by multiplying the expand option with 1.5 (expFactor)). This option can also be overridden with the [data-expand] attribute.
Yes, already thought about adding it to the FAQ, too, will do that.
Has this functionality been changed in your plugin?
No, the plugin does not change any values of the lazysizes script config. The number in the example was only that: an example to show how to adjust it 🙂
Best,
Florian
Hi @martychc23,
I will set this to resolve for now. If you have further issues with that, just add a comment here.
Best,
Florian