1window.addEventListener("load", function (event) { 2 // lazy loads elements with default selector as '.lozad' 3 const svgObserver = lozad('.combo-lazy-svg-injection', { 4 load: function (el) { 5 // Custom implementation to load the svg element 6 SVGInjector(el, { 7 each: function (svg) { 8 // Style copy (max width) 9 // If any error, svg is a string with the error 10 // Example: `Unable to load SVG file: http://doku/_media/ui/preserveaspectratio.svg` 11 if (typeof svg === 'object') { 12 if (el.hasOwnProperty("style")) { 13 svg.style.cssText = el.style.cssText; 14 } 15 if (el.hasOwnProperty("dataset")) { 16 let dataSet = el.dataset; 17 if (dataSet.hasOwnProperty("class")) { 18 dataSet.class.split(" ").forEach(e => svg.classList.add(e)); 19 } 20 } 21 } 22 }, 23 } 24 ) 25 }, 26 loaded: function (el) { 27 // Custom implementation on a loaded element 28 el.classList.add('combo-loaded'); 29 } 30 }); 31 svgObserver.observe(); 32}); 33