Skip to content

Instantly share code, notes, and snippets.

@thedvlprs
Created May 30, 2019 17:38
Show Gist options
  • Save thedvlprs/1c5e1ddd1549bfe9a151b4d35a5443de to your computer and use it in GitHub Desktop.
Save thedvlprs/1c5e1ddd1549bfe9a151b4d35a5443de to your computer and use it in GitHub Desktop.
Ускорение загрузки страницы за счёт параллельной загрузки картинок, вместо последовательной
(async ()=>{
for (let node of document.getElementsByTagName('img')) {
await new Promise(res=>{
node.src=node.dataset.src;
node.onload = ()=>res();
})
}
})()
// Используется data-src вместо src
// Ускорение загрузки страницы за счёт параллельной загрузки картинок, вместо последовательной.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment