PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.8
Elementor Website Builder – more than just a page builder v3.25.8
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/lazyload/module.php +27 -29 4.2.33.25.8 View file →
@@ -4,9 +4,9 @@
4 4 use Elementor\Core\Base\Module as BaseModule;
5 5 use Elementor\Plugin;
6 6
7 7 if ( ! defined( 'ABSPATH' ) ) {
8 - exit; // Exit if accessed directly.
8 + exit; // Exit if accessed directly
9 9 }
10 10
11 11 class Module extends BaseModule {
12 12
@@ -25,9 +25,9 @@
25 25 return;
26 26 }
27 27
28 28 add_action( 'wp_head', function() {
29 - if ( ! $this->should_lazy_load_background_images() ) {
29 + if ( ! $this->should_lazyload() ) {
30 30 return;
31 31 }
32 32 ?>
33 33 <style>
@@ -51,45 +51,43 @@
51 51 <?php
52 52 } );
53 53
54 54 add_action( 'wp_footer', function() {
55 - if ( ! $this->should_lazy_load_background_images() ) {
55 + if ( ! $this->should_lazyload() ) {
56 56 return;
57 57 }
58 58 ?>
59 - <script>
60 - ( () => {
61 - const lazyloadRunObserver = () => {
62 - const lazyloadBackgrounds = document.querySelectorAll( `.e-con.e-parent:not(.e-lazyloaded)` );
63 - const lazyloadBackgroundObserver = new IntersectionObserver( ( entries ) => {
64 - entries.forEach( ( entry ) => {
65 - if ( entry.isIntersecting ) {
66 - let lazyloadBackground = entry.target;
67 - if( lazyloadBackground ) {
68 - lazyloadBackground.classList.add( 'e-lazyloaded' );
69 - }
70 - lazyloadBackgroundObserver.unobserve( entry.target );
59 + <script type='text/javascript'>
60 + const lazyloadRunObserver = () => {
61 + const lazyloadBackgrounds = document.querySelectorAll( `.e-con.e-parent:not(.e-lazyloaded)` );
62 + const lazyloadBackgroundObserver = new IntersectionObserver( ( entries ) => {
63 + entries.forEach( ( entry ) => {
64 + if ( entry.isIntersecting ) {
65 + let lazyloadBackground = entry.target;
66 + if( lazyloadBackground ) {
67 + lazyloadBackground.classList.add( 'e-lazyloaded' );
71 68 }
72 - });
73 - }, { rootMargin: '200px 0px 200px 0px' } );
74 - lazyloadBackgrounds.forEach( ( lazyloadBackground ) => {
75 - lazyloadBackgroundObserver.observe( lazyloadBackground );
76 - } );
77 - };
78 - const events = [
79 - 'DOMContentLoaded',
80 - 'elementor/lazyload/observe',
81 - ];
82 - events.forEach( ( event ) => {
83 - document.addEventListener( event, lazyloadRunObserver );
69 + lazyloadBackgroundObserver.unobserve( entry.target );
70 + }
71 + });
72 + }, { rootMargin: '200px 0px 200px 0px' } );
73 + lazyloadBackgrounds.forEach( ( lazyloadBackground ) => {
74 + lazyloadBackgroundObserver.observe( lazyloadBackground );
84 75 } );
85 - } )();
76 + };
77 + const events = [
78 + 'DOMContentLoaded',
79 + 'elementor/lazyload/observe',
80 + ];
81 + events.forEach( ( event ) => {
82 + document.addEventListener( event, lazyloadRunObserver );
83 + } );
86 84 </script>
87 85 <?php
88 86 } );
89 87 }
90 88
91 - private function should_lazy_load_background_images(): bool {
89 + private function should_lazyload() {
92 90 return ! is_admin() && ! Plugin::$instance->preview->is_preview_mode() && ! Plugin::$instance->editor->is_edit_mode();
93 91 }
94 92
95 93 private static function is_lazy_load_background_images_enabled(): bool {