Line 140: | Line 140: | ||
+ | <script> | ||
+ | |||
+ | (() => { | ||
+ | 'use strict'; | ||
+ | // Page is loaded | ||
+ | const objects = document.getElementsByClassName('team-page-banner'); | ||
+ | Array.from(objects).map((item) => { | ||
+ | // Start loading image | ||
+ | const img = new Image(); | ||
+ | img.src = item.dataset.src; | ||
+ | // Once image is loaded replace the src of the HTML element | ||
+ | |||
+ | img.onload = () => { | ||
+ | item.classList.remove('team-page-banner'); | ||
+ | return item.nodeName === 'IMG' ? | ||
+ | item.src = item.dataset.src : | ||
+ | item.style.backgroundImage = `url(${item.dataset.src})`; | ||
+ | }; | ||
+ | }); | ||
+ | })(); | ||
+ | |||
+ | </script> | ||
Revision as of 15:37, 14 October 2018