BACK ⟲
Scris de Marius Chiriac

Lazy loading nativ pentru imaginile din website

“Lazy loading” este un mod de incarcare a imaginilor intr-un website care ajuta cu viteza a unei pagini web prin decalarea incarcarii pozelor pana cand acestea intra in zona vizibila a ferestrei la scroll. Acest lucru este foarte util in special pentru website-urile care au multe poze de incarcat, in special pe varianta de mobil.

Sunt multiple moduri in care un website poate implementa lazy loading. Poti incerca unul din multele plugin-uri sau librarii ce ofera aceasta functionalitate sau poti incerca sa o introduci folosind noul mod nativ direct in codul tau.

Folosirea unui plugin deobicei ofera o compatibilitate sporita cu browserele majore si setari avansate mult mai granulare. Singurul dezavantaj este faptul ca trebuie sa incarci cod extra third-party in website, lucru pe care uneori nu vrei sa il faci.

Desi nu este inca complet compatibil cu toate browserele (Safari inca nu supporta acest lucru in mod implicit), incarcarea nativa de tip lazy loading este indeajuns de prezenta acum online sa fie o alternativa viabila. Pentru mai multe detalii legat de compatibilitate poti accesa site-ul caniuse.com.

Modul in care activezi lazy loading nativ pentru poze este prin adaugarea atributului loading=”lazy”, acestea fiind incarcate doar dupa ce vizitatorul ajunge la ele prin scroll:

<img src=”poza.jpg” loading=”lazy” alt=”poza” width=”220″ height=”220″>

Pentru a evita modificari de layout in timp ce se incarca pozele este recomandat sa fie folosite atributele de width si height sau sa fie specificate aceste valori in css. Daca pozele nu au o dimensiune specificata este posibil sa fie folosita valoarea implicita de 0 pixeli (0x0) lucru care poate crea probleme daca toate pozele incap in primul ecran (above-the-fold) la incarcare, ele incepand sa se incarce toate. Pentru pozele care sunt in mod normal in primul ecran este recomandat sa nu se foloseasca lazy loading.

Un exemplu bun de cat de mari pot fi beneficiile este website-ul nostru inoveo.ro unde avem pe homepage un numar foarte mare de poze. Fara lazy loading site-ul ar avea de incarcat in jur de 12MB in total, dar cu lazy loading activat un vizitator incarca doar 3MB initial si restul apare treptat la scroll.

Daca ai nevoie ca site-ul sa se incarce mai repede lazy loading te va ajuta asa cum ne-a ajutat pe noi si o poti folosi impreuna cu numeroase alte metode de imbunatatire a performantei unui website. Ca orice alta functionalitate noua, este bine sa testezi bine inainte si dupa si sa vezi efectele ce le are asupra vizitatorilor.

More posts

What large and small companies ask of branding

Small companies ask branding for a clear identity, while large companies ask for a system that keeps it the same in dozens of places. In the INOVEO archive, companies with revenue above 250 million lei [...]

Read More... from Lazy loading nativ pentru imaginile din website

Read the post

What each industry asks of its brand

Brand accounts for 32% of the purchase decision in technology and 67% in luxury, according to Interbrand. That is why each industry asks something different of its brand, depending on where and how fast its [...]

Read More... from Lazy loading nativ pentru imaginile din website

Read the post

Which branding work you do together, and in what order

Branding work delivers results when it is done as a system, in the order in which each piece supports the next: strategy first, then identity, then applications. The wrong order costs twice: an identity made [...]

Read More... from Lazy loading nativ pentru imaginile din website

Read the post

Branding for companies outside Bucharest

About 73% of Romania’s economy is produced outside the capital, and the companies there have a brand argument that is hard to copy: the place they come from. In the INOVEO archive, 45% of clients [...]

Read More... from Lazy loading nativ pentru imaginile din website

Read the post

INOVEO
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.