{"id":268,"date":"2020-02-05T07:41:39","date_gmt":"2020-02-05T07:41:39","guid":{"rendered":"https:\/\/stockpack.co\/blog\/?p=268"},"modified":"2020-06-11T16:29:13","modified_gmt":"2020-06-11T16:29:13","slug":"image-lazy-loading","status":"publish","type":"post","link":"https:\/\/stockpack.co\/blog\/image-lazy-loading\/","title":{"rendered":"Image lazy loading"},"content":{"rendered":"\n<p>Mobile traffic has crossed the 50% mark some time ago. That is a huge incentive for webmasters to increase their page performances.<\/p>\n\n\n\n<p>One of the most effective ways to increase the speed of a page in WordPress or any other platform is <strong>lazy loading images<\/strong>. <\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">What is lazy loading<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/bear-predator-zoo-stockpack-pixabay-1024x683.jpeg\" alt=\"bear, predator, zoo\" class=\"wp-image-270\" srcset=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/bear-predator-zoo-stockpack-pixabay-1024x683.jpeg 1024w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/bear-predator-zoo-stockpack-pixabay-300x200.jpeg 300w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/bear-predator-zoo-stockpack-pixabay-768x512.jpeg 768w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/bear-predator-zoo-stockpack-pixabay-1536x1024.jpeg 1536w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/bear-predator-zoo-stockpack-pixabay-2048x1366.jpeg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Photo by <a href=\"https:\/\/pixabay.com\/users\/raincarnation40?utm_source=Stockpack&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\">raincarnation40<\/a> on <a href=\"https:\/\/pixabay.com\/photos\/1383980?utm_source=Stockpack&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\">Pixabay<\/a><\/figcaption><\/figure>\n\n\n\n<p><strong>Lazy is a short name for optimum<\/strong>. Well, that is definitely true in tech, but it&#8217;s sometimes true in life maybe? <\/p>\n\n\n\n<p>Anyway, what that means is to only load images when they are actually needed. For example. If your website has 10 images on your homepage, the user would download all those 10 images to see it. <\/p>\n\n\n\n<p>In some cases, especially on mobile, the user might not need to see any of them, so that&#8217;s a waste of his time and your server resources. If he clicks the first button and goes to the next page then he probably only needed the first image. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Image lazy loading is eco friendly \ud83c\udf0d<\/h2>\n\n\n\n<p>Image lazy loading is helping save the planet. While helping your site, you are also helping the planet. How cool is that right?<\/p>\n\n\n\n<p>Due to the fact that some users might not read all your articles to the end (some might get the point faster), they will not load all the images. You just saved the electricity which would have been used to download that image to the user computer and to render it. Its not much, but every bit helps!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you add lazy loading<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"948\" src=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/thinking-stockpack-unsplash-1024x948.jpeg\" alt=\"Thinking\" class=\"wp-image-271\" srcset=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/thinking-stockpack-unsplash-1024x948.jpeg 1024w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/thinking-stockpack-unsplash-300x278.jpeg 300w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/thinking-stockpack-unsplash-768x711.jpeg 768w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/thinking-stockpack-unsplash-1536x1422.jpeg 1536w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/thinking-stockpack-unsplash-2048x1896.jpeg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Photo by <a href=\"https:\/\/unsplash.com\/@designwilde?utm_source=Stockpack&amp;utm_medium=referral&amp;utm_campaign=api-credit\" target=\"_blank\" rel=\"noopener noreferrer\">Melanie Dretvic<\/a> on <a href=\"https:\/\/unsplash.com\/photos\/uq1pGPS0910?utm_source=StockPack&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<p>There are a ton of plugins out there that you can use to lazy load images in WordPress. <\/p>\n\n\n\n<p>My personal favorite is <a href=\"https:\/\/wordpress.org\/plugins\/a3-lazy-load\/\">https:\/\/wordpress.org\/plugins\/a3-lazy-load\/<\/a> because you can lazy load iframes and videos as well. However, I don&#8217;t like any performance plugin as they tend to be quite complicated and bloated. I think every plugin should optimize itself, but that&#8217;s another story.<\/p>\n\n\n\n<p>So just install that plugin and you will get lazy loading in WordPress. That is what you need to do at this time. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is native lazy loading<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/google-logo-screengrab-stockpack-unsplash-1024x683.jpeg\" alt=\"Google logo screengrab\" class=\"wp-image-272\" srcset=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/google-logo-screengrab-stockpack-unsplash-1024x683.jpeg 1024w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/google-logo-screengrab-stockpack-unsplash-300x200.jpeg 300w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/google-logo-screengrab-stockpack-unsplash-768x512.jpeg 768w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/google-logo-screengrab-stockpack-unsplash-1536x1024.jpeg 1536w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/google-logo-screengrab-stockpack-unsplash-2048x1365.jpeg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Photo by <a href=\"https:\/\/unsplash.com\/@christianw?utm_source=Stockpack&amp;utm_medium=referral&amp;utm_campaign=api-credit\" target=\"_blank\" rel=\"noopener noreferrer\">Christian Wiediger<\/a> on <a href=\"https:\/\/unsplash.com\/photos\/zhZydTyNMPg?utm_source=StockPack&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<p>Native lazy loading is something Google Chrome is supporting starting with Chrome 76. <\/p>\n\n\n\n<p>What this means is that you will not need any specific plugin to do it, and it will work by just setting the <code>loading<\/code> attribute. <\/p>\n\n\n\n<figure class=\"wp-block-embed-twitter aligncenter wp-block-embed is-type-rich is-provider-twitter\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"twitter-tweet\" data-width=\"550\" data-dnt=\"true\"><p lang=\"en\" dir=\"ltr\">Native &lt;img&gt; lazy-loading is coming to the web! <a href=\"https:\/\/t.co\/LgF7F1iMgR\">https:\/\/t.co\/LgF7F1iMgR<\/a> &lt;img loading=lazy&gt; defers offscreen images until the user scrolls near them. Shipping in Chrome ~75 <a href=\"https:\/\/t.co\/4gR7lvx4zx\">https:\/\/t.co\/4gR7lvx4zx<\/a> <a href=\"https:\/\/t.co\/luCHEfLkKD\">pic.twitter.com\/luCHEfLkKD<\/a><\/p>&mdash; Addy Osmani (@addyosmani) <a href=\"https:\/\/twitter.com\/addyosmani\/status\/1114777583302799360?ref_src=twsrc%5Etfw\">April 7, 2019<\/a><\/blockquote><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<\/div><\/figure>\n\n\n\n<p>WordPress is going to introduce support for it meaning you might get a set when inserting images through the media library. This is a good thing, as you won&#8217;t need extra scripts for lazy loading. <\/p>\n\n\n\n<p>However, this only applies to images for now. If you have iframes and videos, you still need the plugin.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Going further<\/h2>\n\n\n\n<p>Performance for images is something that can automatically be done, so you are in luck. Other things like scripts and css will probably be your problem. <\/p>\n\n\n\n<p>To find out more about images best practices check: <a href=\"http:\/\/image\">5 simple image tricks that go a long way in WordPress<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mobile traffic has crossed the 50% mark some time ago. That is a huge incentive for webmasters to increase their page performances. One of the most effective ways to increase the speed of a page in WordPress or any other platform is lazy loading images.<\/p>\n","protected":false},"author":1,"featured_media":269,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12,8],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-images","category-news","category-wordpress"],"_links":{"self":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":3,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/268\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/268\/revisions\/379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media\/269"}],"wp:attachment":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media?parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/categories?post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/tags?post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}