### LazyLoad Initialization and Configuration Source: https://akademicevre.com/cevre-bilimi/ Demonstrates how to initialize the LazyLoad library with custom configurations. It shows the basic setup for applying lazy loading to elements on a webpage. ```javascript var myLazyLoad = new LazyLoad({ elements_selector: ".lazy", threshold: 0, callback_load: function(el) { // Element loaded } }); ``` -------------------------------- ### LazyLoad Initialization and Configuration Source: https://akademicevre.com/akademi-cevre-surdurulebilir-sohbetler-youtube-projesi/ Demonstrates how to initialize the LazyLoad library with various configuration options. It covers setting up observers, callbacks, and class names for managing the loading state of elements. ```javascript var lazyLoadInstance = new LazyLoad(options); // Example options: var options = { elements_selector: ".lazy", // Selector for elements to lazy load container: document.section, // Optional container element threshold: 300, // Distance in pixels to the element when it should be loaded throttle: 100, // Throttle interval for intersection observer callback_load: function(element) { /* ... */ }, // Callback when element is loaded callback_error: function(element) { /* ... */ }, // Callback when element fails to load callback_set: function(element) { /* ... */ }, // Callback when element attributes are set callback_applied: function(element) { /* ... */ }, // Callback when background image is applied callback_ready: function(element) { /* ... */ }, // Callback when element is ready callback_finish: function(instance) { /* ... */ }, // Callback when all elements are loaded class_loading: "loading", // Class added while loading class_loaded: "loaded", // Class added when loaded class_error: "error", // Class added on error class_applied: "applied", // Class added when background is applied class_entered: "entered", // Class added when element enters viewport class_exited: "exited", // Class added when element exits viewport data_src: "src", // Attribute for image src data_srcset: "srcset", // Attribute for image srcset data_sizes: "sizes", // Attribute for image sizes data_bg: "bg", // Attribute for background image URL data_bg_multi: "bg-multi", // Attribute for multiple background images data_bg_multi_hidpi: "bg-multi-hidpi", // Attribute for high-res multiple background images data_bg_hidpi: "bg-hidpi", // Attribute for high-res background image URL data_sizes_attr: "sizes", // Attribute for sizes attribute data_srcset_attr: "srcset", // Attribute for srcset attribute skip_invisible: true, // Skip invisible elements include_data_src: false, // Include data-src for images unobserve_completed: true, // Unobserve elements after loading unobserve_skipped: false, // Unobserve skipped elements use_native: true, // Use native lazy loading if available preLoad: 1.5, // Preload elements within this threshold observe_children: true // Observe children of elements }; ``` -------------------------------- ### LazyLoad Initialization for WordPress/Elementor Source: https://akademicevre.com/uluslararasi-cevre-zirvesi/ Example of how LazyLoad might be integrated or configured within a WordPress environment, potentially using Elementor. It shows the typical JavaScript variables and initialization patterns found in such setups. ```javascript var _wpUtilSettings = { "ajax": { "url": "\/wp-admin\/admin-ajax.php" } }; var wpformsElementorVars = { "captcha_provider": "recaptcha", "recaptcha_type": "v2" }; // Assuming LazyLoad is loaded and available globally // Example initialization (actual config might vary): // var lazyLoadInstance = new LazyLoad({ // elements_selector: ".lazyload", // threshold: 300 // }); ``` -------------------------------- ### Post Data Example Source: https://akademicevre.com/temiz-su-ve-sanitasyon/ Example of post data structure, including ID, title, excerpt, and featured image status. ```json {"post":{"id":12892,"title":"Temiz%20Su%20ve%20Sanitasyon%20-%20Akademi%20%C3%87evre","excerpt":"","featuredImage":!1}} ``` -------------------------------- ### LazyLoad Initialization and Configuration Source: https://akademicevre.com/televizyon-ve-monitorler/ Demonstrates how to initialize the LazyLoad library with custom configurations. It covers setting up options like callbacks, class names for different states, and observer behavior. ```javascript var myLazyLoad = new LazyLoad({ elements_selector: ".lazy", threshold: 0, callback_load: function(el) { // Custom logic when an element is loaded console.log('Element loaded:', el); }, callback_error: function(el) { // Custom logic when an element fails to load console.log('Element error:', el); } }); ``` -------------------------------- ### WordPress Configuration Example Source: https://akademicevre.com/turkiye-ve-dunyada-surdurulebilirlik/ Example of WordPress-specific configuration variables, likely used by plugins or themes. This includes settings for AJAX URLs and reCAPTCHA providers for forms. ```json { "viewport_mobile": "viewport_tablet" ], "global_image_lightbox": "yes", "lightbox_enable_counter": "yes", "lightbox_enable_fullscreen": "yes", "lightbox_enable_zoom": "yes", "lightbox_enable_share": "yes", "lightbox_title_src": "title", "lightbox_description_src": "description", "hello_header_logo_type": "logo", "hello_header_menu_layout": "horizontal", "hello_footer_logo_type": "logo" } ``` ```json { "ajax": { "url": "\/wp-admin\/admin-ajax.php" } } ``` ```json { "captcha_provider": "recaptcha", "recaptcha_type": "v2" } ``` -------------------------------- ### LazyLoad Initialization and Configuration Source: https://akademicevre.com/karbon-salinimi/ Demonstrates how to initialize the LazyLoad library with custom configurations. It covers setting options for loading images, background images, and handling various callbacks for different loading states. ```javascript function LazyLoad(options) { // ... library code ... } // Example Initialization with options: const lazyLoadInstance = new LazyLoad({ elements_selector: ".lazy", container: document.getElementById('scroll-container'), threshold: 200, callback_load: (el) => { console.log('Element loaded:', el); }, callback_error: (el) => { console.log('Error loading element:', el); }, callback_finish: (instance) => { console.log('All elements loaded:', instance); } }); // For background images: const lazyLoadBgInstance = new LazyLoad({ selector: ".lazy-background", callback_applied: (el) => { console.log('Background applied:', el); } }); // For video elements: const lazyLoadVideoInstance = new LazyLoad({ selector: ".lazy-video", elements_to_load: "video" }); ``` -------------------------------- ### LazyLoad Initialization and Configuration Source: https://akademicevre.com/ekosistem-hizmetleri/ Demonstrates how to initialize the LazyLoad library with various configuration options. It covers setting up callbacks for loading states, defining classes for styling, and managing observer behavior. ```javascript var lazyLoadInstance = new LazyLoad({ elements_selector: ".lazy", threshold: 0, rootMargin: "0px", thresholds: null, data_src: "src", data_srcset: "srcset", data_sizes: "sizes", data_bg: "bg", data_bg_hidpi: "bg-hidpi", data_bg_multi: "bg-multi", data_bg_multi_hidpi: "bg-multi-hidpi", data_poster: "poster", class_applied: "applied", class_loading: "loading", class_loaded: "loaded", class_error: "error", class_entered: "entered", class_exited: "exited", class_native_loading: "native-loading", class_native_error: "native-error", load_delay: 200, auto_unobserve: true, callback_load: null, callback_loaded: null, callback_error: null, callback_finish: null, callback_enter: null, callback_exit: null, callback_reveal: null, callback_set: null, callback_applied: null, callback_native_loaded: null, callback_native_error: null, observe_children: true, cancel_on_exit: true, callback_cancel: null, use_native: true, root: null, unobserve_completed: true, skip_invisible: true, delay_load: 0 }); // Example of using the instance // lazyLoadInstance.update(); ``` -------------------------------- ### Intersection Observer Setup and Callback Handling Source: https://akademicevre.com/iklim-finansmani/ Handles the setup of the IntersectionObserver, including root, rootMargin, and thresholds. It also defines the callback function that processes intersection changes, triggering load or exit logic based on element state. ```javascript function J(e,n){var t;et&&!H(e)&&(n._observer=new IntersectionObserver(function(t){B(t,e,n)},{root:(t=e).container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}))} function B(t,i,o){t.forEach(function(t){return(a=t).isIntersecting||0 0; }; var isNotVisible = function(entry) { return entry.intersectionRatio === 0; }; var isElement = function(element) { return element instanceof Element; }; var isNodeList = function(nodeList) { return nodeList instanceof NodeList; }; var isHTMLCollection = function(htmlCollection) { return htmlCollection instanceof HTMLCollection; }; var isArray = function(array) { return Array.isArray(array); }; var isObject = function(obj) { return obj && typeof obj === 'object' && !Array.isArray(obj); }; var isFunction = function(fn) { return typeof fn === 'function'; }; var isString = function(str) { return typeof str === 'string'; }; var isNullOrUndefined = function(val) { return val === null || val === undefined; }; var isElementLoadedOrError = function(element) { return isElementLoaded(element) || isElementError(element); }; var isElementLoadingOrApplied = function(element) { return isElementLoading(element) || isElementApplied(element); }; var isElementEntered = function(element) { return element.classList.contains(config.class_entered); }; var isElementExited = function(element) { return element.classList.contains(config.class_exited); }; var addClassEntered = function(element, config) { addClass(element, config.class_entered); }; var addClassExited = function(element, config) { addClass(element, config.class_exited); }; var removeClassEntered = function(element, config) { removeClass(element, config.class_entered); }; var removeClassExited = function(element, config) { removeClass(element, config.class_exited); }; var addClassLoading = function(element, config) { addClass(element, config.class_loading); }; var addClassLoaded = function(element, config) { addClass(element, config.class_loaded); }; var addClassError = function(element, config) { addClass(element, config.class_error); }; var addClassApplied = function(element, config) { addClass(element, config.class_applied); }; var removeClassLoading = function(element, config) { removeClass(element, config.class_loading); }; var removeClassLoaded = function(element, config) { removeClass(element, config.class_loaded); }; var removeClassError = function(element, config) { removeClass(element, config.class_error); }; var removeClassApplied = function(element, config) { removeClass(element, config.class_applied); }; var setAttributeSrc = function(element, value) { setAttribute(element, 'src', value); }; var setAttributeSrcset = function(element, value) { setAttribute(element, 'srcset', value); }; var setAttributeSizes = function(element, value) { setAttribute(element, 'sizes', value); }; var setAttributeBg = function(element, value) { setAttribute(element, 'background', value); }; var setAttributeBgHiDPI = function(element, value) { setAttribute(element, 'background-image', value); }; var setAttributeBgMulti = function(element, value) { setAttribute(element, 'background-image', value); }; var setAttributeBgMultiHiDPI = function(element, value) { setAttribute(element, 'background-image', value); }; var removeAttributeSrc = function(element) { removeAttribute(element, 'src'); }; var removeAttributeSrcset = function(element) { removeAttribute(element, 'srcset'); }; var removeAttributeSizes = function(element) { removeAttribute(element, 'sizes'); }; var removeAttributeBg = function(element) { removeAttribute(element, 'background'); }; var removeAttributeBgHiDPI = function(element) { removeAttribute(element, 'background-image'); }; var removeAttributeBgMulti = function(element) { removeAttribute(element, 'background-image'); }; var removeAttributeBgMultiHiDPI = function(element) { removeAttribute(element, 'background-image'); }; var getAttributeSrc = function(element) { return getAttribute(element, 'src'); }; var getAttributeSrcset = function(element) { return getAttribute(element, 'srcset'); }; var getAttributeSizes = function(element) { return getAttribute(element, 'sizes'); }; var getAttributeBg = function(element) { return getAttribute(element, 'background'); }; var getAttributeBgHiDPI = function(element) { return getAttribute(element, 'background-image'); }; var getAttributeBgMulti = function(element) { return getAttribute(element, 'background-image'); }; var getAttributeBgMultiHiDPI = function(element) { return getAttribute(element, 'background-image'); }; var getAttributeDataSrc = function(element) { return getAttribute(element, config.data_src); }; var getAttributeDataSrcset = function(element) { return getAttribute(element, config.data_srcset); }; var getAttributeDataSizes = function(element) { return getAttribute(element, config.data_sizes); }; var getAttributeDataBg = function(element) { return getAttribute(element, config.data_bg); }; var getAttributeDataBgHiDPI = function(element) { return getAttribute(element, config.data_bg_hidpi); }; var getAttributeDataBgMulti = function(element) { return getAttribute(element, config.data_bg_multi); }; var getAttributeDataBgMultiHiDPI = function(element) { return getAttribute(element, config.data_bg_multi_hidpi); }; var getAttributeDataBgMultiValues = function(element) { var bgMulti = getAttributeDataBgMulti(element); var bgMultiHiDPI = getAttributeDataBgMultiHiDPI(element); return bgMultiHiDPI ? bgMultiHiDPI : bgMulti; }; var getAttributeDataBgValues = function(element) { var bg = getAttributeDataBg(element); var bgHiDPI = getAttributeDataBgHiDPI(element); return bgHiDPI ? bgHiDPI : bg; }; var getAttributeDataSrcValues = function(element) { var src = getAttributeDataSrc(element); var srcset = getAttributeDataSrcset(element); var sizes = getAttributeDataSizes(element); return { src: src, srcset: srcset, sizes: sizes }; }; var setAttributeForImage = function(element, data) { setAttributeSrc(element, data.src); setAttributeSrcset(element, data.srcset); setAttributeSizes(element, data.sizes); }; var setAttributeForBackground = function(element, data) { element.style.backgroundImage = 'url("' + data.src + '")'; }; var setAttributeForBackgroundMulti = function(element, data) { element.style.backgroundImage = data; }; var loadAndProcess = function(element, instance) { var data = getAttributeDataSrcValues(element); var bgData = getAttributeDataBgValues(element); var bgMultiData = getAttributeDataBgMultiValues(element); if (data.src || bgData || bgMultiData) { setStatus(element, 'loading'); addClassLoading(element, config); callbackLoading(element, instance); if (data.src) { var tempImage = new Image(); tempImage.llTempImage = element; tempImage.onload = function() { setAttributeForImage(element, data); removeClassLoading(element, config); addClassLoaded(element, config); setStatus(element, 'loaded'); callbackLoad(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } deleteTempImage(element); }; tempImage.onerror = function() { removeClassLoading(element, config); addClassError(element, config); setStatus(element, 'error'); callbackError(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } deleteTempImage(element); }; tempImage.src = data.src; } else if (bgData) { setAttributeForBackground(element, bgData); removeClassLoading(element, config); addClassLoaded(element, config); setStatus(element, 'loaded'); callbackLoad(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } } else if (bgMultiData) { setAttributeForBackgroundMulti(element, bgMultiData); removeClassLoading(element, config); addClassLoaded(element, config); setStatus(element, 'loaded'); callbackLoad(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } } } else { setStatus(element, 'skipped'); if (config.unobserve_skipped) { observer.unobserve(element); } } }; var loadBackground = function(element, instance) { var bgData = getAttributeDataBgValues(element); var bgMultiData = getAttributeDataBgMultiValues(element); if (bgData || bgMultiData) { setStatus(element, 'loading'); addClassLoading(element, config); callbackLoading(element, instance); if (bgData) { var tempImage = new Image(); tempImage.llTempImage = element; tempImage.onload = function() { setAttributeForBackground(element, bgData); removeClassLoading(element, config); addClassLoaded(element, config); setStatus(element, 'loaded'); callbackLoad(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } deleteTempImage(element); }; tempImage.onerror = function() { removeClassLoading(element, config); addClassError(element, config); setStatus(element, 'error'); callbackError(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } deleteTempImage(element); }; tempImage.src = bgData; } else if (bgMultiData) { setAttributeForBackgroundMulti(element, bgMultiData); removeClassLoading(element, config); addClassLoaded(element, config); setStatus(element, 'loaded'); callbackLoad(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } } } else { setStatus(element, 'skipped'); if (config.unobserve_skipped) { observer.unobserve(element); } } }; var loadAndApply = function(element, instance) { var data = getAttributeDataSrcValues(element); if (data.src || data.srcset || data.sizes) { setStatus(element, 'applied'); addClassApplied(element, config); callbackApplied(element, instance); if (config.unobserve_completed) { observer.unobserve(element); } } }; var handleIntersection = function(entries, observer) { entries.forEach(function(entry) { var element = entry.target; if (isIntersecting(entry)) { if (!isElementObserved(element)) { loadAndProcess(element, instance); loadBackground(element, instance); loadAndApply(element, instance); callbackEnter(element, instance); addClassEntered(element, config); } } else { callbackExit(element, instance); addClassExited(element, config); } }); }; var initObserver = function() { if (typeof IntersectionObserver !== 'undefined') { var observerOptions = { rootMargin: config.rootMargin, threshold: config.thresholds || config.threshold }; if (config.observer_options) { Object.assign(observerOptions, config.observer_options); } observer = new IntersectionObserver(handleIntersection, observerOptions); elements.forEach(function(element) { observer.observe(element); }); } else { console.warn('LazyLoad: IntersectionObserver not supported. Falling back to manual loading.'); elements.forEach(function(element) { loadAndProcess(element, instance); loadBackground(element, instance); loadAndApply(element, instance); }); } }; var findElements = function() { var elementsToLoad = []; var selector = config.elements_selector; var container = config.container; if (container) { var containerElements = container.querySelectorAll(selector); containerElements.forEach(function(el) { elementsToLoad.push(el); }); } else { var allElements = document.querySelectorAll(selector); allElements.forEach(function(el) { elementsToLoad.push(el); }); } elements = elementsToLoad; }; var init = function() { findElements(); initObserver(); }; instance.destroy = function() { if (observer) { observer.disconnect(); } elements.forEach(function(element) { if (element.llTempImage) { delete element.llTempImage; } if (element.classList.contains(config.class_loading)) { removeClassLoading(element, config); } if (element.classList.contains(config.class_loaded)) { removeClassLoaded(element, config); } if (element.classList.contains(config.class_error)) { removeClassError(element, config); } if (element.classList.contains(config.class_applied)) { removeClassApplied(element, config); } if (element.classList.contains(config.class_entered)) { removeClassEntered(element, config); } if (element.classList.contains(config.class_exited)) { removeClassExited(element, config); } element.removeAttribute('data-ll-status'); }); elements = []; instance.loadedCount = 0; instance.toLoadCount = 0; }; instance.update = function() { findElements(); initObserver(); }; instance.loadedCount = 0; instance.toLoadCount = elements.length; instance.container = config.container; instance.observer = observer; instance.config = config; init(); return instance; } ``` -------------------------------- ### LazyLoad Initialization and Configuration Source: https://akademicevre.com/atik-yonetimi-danismanligi/ Demonstrates how to initialize the LazyLoad library with various configuration options. This includes setting thresholds, classes for different states, and callbacks for loading events. ```javascript var lazyLoadInstance = new LazyLoad({ elements_selector: ".lazy", threshold: 0, callback_load: function(el) { // Called after an element is loaded console.log('Element loaded:', el); }, callback_error: function(el) { // Called when an element fails to load console.log('Element error:', el); }, callback_finish: function(llInstance) { // Called when all elements are loaded or failed console.log('LazyLoad finished:', llInstance); } }); ``` -------------------------------- ### LiteSpeed UI Event Listener Setup Source: https://akademicevre.com/iklim-eylemi/ Defines an array of user interface events that are monitored by LiteSpeed for triggering delayed JavaScript loading. ```javascript const litespeed_ui_events=["mouseover","click","keydown","wheel","touchmove","touchstart"]; ``` -------------------------------- ### LiteSpeed UI Event Listener Setup Source: https://akademicevre.com/entegre-raporlama/ Defines an array of user interface events that are monitored by LiteSpeed for triggering delayed JavaScript loading. ```javascript const litespeed_ui_events=["mouseover","click","keydown","wheel","touchmove","touchstart"]; ```