Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 25, 2022 02:54 pm GMT

Ways to increase images load time speed on webpages / sites

  1. When loading a background image in a section or div of a website, it is neccessary to add an image tag within the div or section with a style display of none to increase the priority for the load time of that background image.
<header class = "hero" style="background-image: url(hero.jpg);"   <img src = "hero.jpg" alt = "" style = "display: none" />   <!-- Content --></header>

The reason is because the browser wont request the background-image until it knows it needs itwhen the Render Tree is built and the Render Tree is only as fast as your slowest stylesheet and this help to get around it, by making the request start much earlier by simply moving it to your markup. HTML is fast because its declarative nature means it can be preload-scanned.

Sourced from: Harry Roberts' Tweet


Original Link: https://dev.to/mrpaulishaili/ways-to-increase-images-load-time-speed-on-webpages-sites-o0a

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To