{"id":69,"date":"2021-01-15T16:18:01","date_gmt":"2021-01-15T15:18:01","guid":{"rendered":"https:\/\/dross.net\/alexander\/blog\/?p=69"},"modified":"2021-03-15T19:15:11","modified_gmt":"2021-03-15T18:15:11","slug":"image-handling","status":"publish","type":"post","link":"https:\/\/dross.net\/alexander\/blog\/image-handling\/","title":{"rendered":"WebDev: Image handling examples for fast loading websites"},"content":{"rendered":"[vc_row type=&#8221;in_container&#8221; full_screen_row_position=&#8221;middle&#8221; column_margin=&#8221;default&#8221; column_direction=&#8221;default&#8221; column_direction_tablet=&#8221;default&#8221; column_direction_phone=&#8221;default&#8221; scene_position=&#8221;center&#8221; text_color=&#8221;dark&#8221; text_align=&#8221;left&#8221; row_border_radius=&#8221;none&#8221; row_border_radius_applies=&#8221;bg&#8221; overlay_strength=&#8221;0.3&#8243; gradient_direction=&#8221;left_to_right&#8221; shape_divider_position=&#8221;bottom&#8221; bg_image_animation=&#8221;none&#8221;][vc_column column_padding=&#8221;no-extra-padding&#8221; column_padding_tablet=&#8221;inherit&#8221; column_padding_phone=&#8221;inherit&#8221; column_padding_position=&#8221;all&#8221; background_color_opacity=&#8221;1&#8243; background_hover_color_opacity=&#8221;1&#8243; column_shadow=&#8221;none&#8221; column_border_radius=&#8221;none&#8221; column_link_target=&#8221;_self&#8221; gradient_direction=&#8221;left_to_right&#8221; overlay_strength=&#8221;0.3&#8243; width=&#8221;2\/3&#8243; tablet_width_inherit=&#8221;default&#8221; tablet_text_alignment=&#8221;default&#8221; phone_text_alignment=&#8221;default&#8221; column_border_width=&#8221;none&#8221; column_border_style=&#8221;solid&#8221; bg_image_animation=&#8221;none&#8221;][vc_column_text]Understand how to use images, image dimensions and lazy load on websites properly to ensure freaking fast loading pages.<br \/>\n<!--more--><br \/>\nThis page explains how to properly use images on websites, to ensure fast loading pages. Below example uses own version of images per each break point rather dann resizing images per html or CSS only.<\/p>\n<p>Each image conatiner will then contain 21 versions of an image: in 5 dimensions as we have 5 break points; 5x webP image format for modern browsers, both formats (JPEG\/ PNG and webP) optimized for retina displays and one fall-back image for older browsers which do not support picture tag.<\/p>\n<p>Version 3 and 8 contain build-in microdata format for structured data markups.<\/p>\n<h2>Different versions on how to handle images on websites:<\/h2>\n<ol>\n<li><a title=\"IMG tag, no lazy load\" href=\"https:\/\/imagehandling.drossmedia.de\/test1.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"IMG tag, no lazy load\">IMG tag, no lazy load<\/a><\/li>\n<li><a title=\"IMG tag + native lazy load + lazy load by Lazysizes\" href=\"https:\/\/imagehandling.drossmedia.de\/test2.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"IMG tag + native lazy load + lazy load by Lazysizes\">IMG tag + native lazy load + lazy load by Lazysizes<\/a>\n<ol>\n<li><a title=\"IMG tag + native lazy load + lazy load by Lazysizes - resolution switching: Same size, different resolutions\" href=\"https:\/\/imagehandling.drossmedia.de\/test2_1.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"IMG tag + native lazy load + lazy load by Lazysizes - resolution switching: Same size, different resolutions\">IMG tag + native lazy load + lazy load by Lazysizes &#8211; resolution switching: Same size, different resolutions<\/a><\/li>\n<li><a title=\"IMG tag + native lazy load + lazy load by Lazysizes - resolution switching: by different sizes\" href=\"https:\/\/imagehandling.drossmedia.de\/test2_2.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"IMG tag + native lazy load + lazy load by Lazysizes - resolution switching: by different sizes\">IMG tag + native lazy load + lazy load by Lazysizes &#8211; resolution switching: by different sizes<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a title=\"IMG tag + native lazy load + lazy load by Lazysizes + Microformat Schema for image SEO\" href=\"https:\/\/imagehandling.drossmedia.de\/test3.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"IMG tag + native lazy load + lazy load by Lazysizes + Microformat Schema for image SEO\"><strong>IMG tag + native lazy load + lazy load by Lazysizes + Microformat Schema for image SEO<\/strong><\/a><\/li>\n<li><a title=\"IMG tag to PICTURE tag + webP, no lazy load\" href=\"https:\/\/imagehandling.drossmedia.de\/test4.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"IMG tag to PICTURE tag + webP, no lazy load\">IMG tag to PICTURE tag + webP, no lazy load<\/a><\/li>\n<li><a title=\"PICTURE tag + webP + native lazy load + lazy load by Lazysizes\" href=\"https:\/\/imagehandling.drossmedia.de\/test5.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"PICTURE tag + webP + native lazy load + lazy load by Lazysizes\">PICTURE tag + webP + native lazy load + lazy load by Lazysizes<\/a><\/li>\n<li><a title=\"PICTURE tag + webP + responsive\/ scaled images, no lazy load\" href=\"https:\/\/imagehandling.drossmedia.de\/test6.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"PICTURE tag + webP + responsive\/ scaled images, no lazy load\">PICTURE tag + webP + responsive\/ scaled images, no lazy load<\/a><\/li>\n<li><a title=\"PICTURE tag + webP + native lazy load + lazy load by Lazysizes + responsive\/ scaled images\" href=\"https:\/\/imagehandling.drossmedia.de\/test7.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"PICTURE tag + webP + native lazy load + lazy load by Lazysizes + responsive\/ scaled images\">PICTURE tag + webP + native lazy load + lazy load by Lazysizes + responsive\/ scaled images<\/a><\/li>\n<li><a title=\"PICTURE tag + webP + native lazy load + lazy load by Lazysizes + responsive\/ scaled images + Microformat Schema for image SEO\" href=\"https:\/\/imagehandling.drossmedia.de\/test8.php\" target=\"_blank\" rel=\"noopener\" aria-label=\"PICTURE tag + webP + native lazy load + lazy load by Lazysizes + responsive\/ scaled images + Microformat Schema for image SEO\"><strong>PICTURE tag + webP + native lazy load + lazy load by Lazysizes + responsive\/ scaled images + Microformat Schema for image SEO<\/strong><\/a><\/li>\n<\/ol>\n<ul>\n<li>3. should be used when using &#8220;img&#8221; tag.<\/li>\n<li>8. should be used when using &#8220;picture&#8221; tag.<\/li>\n<li>above other bullet points are just intermediate steps to better understand the end result.<\/li>\n<li><a title=\"Download image handling package in ZIP file format\" href=\"https:\/\/imagehandling.drossmedia.de\/image-handling.zip\" rel=\"noopener\" aria-label=\"Download image handling package in ZIP file format\">Download image handling package in ZIP file format<\/a><\/li>\n<\/ul>\n<h3>Demo Video: Responsive\/ Scaled Images<\/h3>\n<p><iframe loading=\"lazy\" title=\"YouTube Demo on Responsive\/ Scaled Images\" src=\"https:\/\/www.youtube-nocookie.com\/embed\/RRhPeLuZn_0\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><strong>Requirements:<\/strong><\/p>\n<ul>\n<li>Native lazy load &#8211; (loading=&#8221;lazy&#8221;)<\/li>\n<li>Lazy load of images by Lazysizes, for older browsers &#8211; (class=&#8221;lazyload&#8221;)<\/li>\n<li>Create web ready images and compress them<\/li>\n<li>Displays images with incorrect aspect ratio<\/li>\n<li>webP image formats &#8211; (picture tag and type=&#8221;image\/webp&#8221;)<\/li>\n<li>Responsive\/ scaled images in 5 different dimensions as we use 5 breakpoints &#8211; (img tag: sizes=&#8221;XXvw&#8221;; picture tag: (min-width: XXpx) and (max-width: YYpx))<\/li>\n<li>Optimize reg Cumulative Layout Shits &#8211; (adding image dimensions: width\/ height to each image per breakpoint)<\/li>\n<li>ALT + title tags on images + &#8220;description of the image&#8221;<\/li>\n<li>Optimize with structured data markups in Microdata format &#8211; (adding itemtype=&#8221;https:\/\/schema.org\/ImageObject&#8221;)<\/li>\n<\/ul>\n<p><strong>Sources:<\/strong><\/p>\n<ul>\n<li><a title=\"Use lazysizes to lazyload images on older browsers\" href=\"https:\/\/web.dev\/use-lazysizes-to-lazyload-images\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"Use lazysizes to lazyload images on older browsers\">https:\/\/web.dev\/use-lazysizes-to-lazyload-images\/<\/a><\/li>\n<li><a title=\"create web ready images and compress them\" href=\"https:\/\/web.dev\/uses-optimized-images\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"create web ready images and compress them\">https:\/\/web.dev\/uses-optimized-images\/<\/a><\/li>\n<li><a title=\"Displays images with incorrect aspect ratio\" href=\"https:\/\/web.dev\/image-aspect-ratio\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"Displays images with incorrect aspect ratio\">https:\/\/web.dev\/image-aspect-ratio\/<\/a><\/li>\n<li><a title=\"Use WebP images\" href=\"https:\/\/web.dev\/serve-images-webp\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"Use WebP images\">https:\/\/web.dev\/serve-images-webp\/<\/a><\/li>\n<li><a title=\"Serve responsive images for each break point + retina display\" href=\"https:\/\/web.dev\/serve-responsive-images\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"Serve responsive images for each break point + retina display\">https:\/\/web.dev\/serve-responsive-images\/<\/a><\/li>\n<li><a title=\"Optimize Cumulative Layout Shift\" href=\"https:\/\/web.dev\/optimize-cls\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"Optimize Cumulative Layout Shift\">https:\/\/web.dev\/optimize-cls\/<\/a><\/li>\n<li><a title=\"Use structured data markup in Microdata format to optimize images for SEO\" href=\"https:\/\/schema.org\/ImageObject#examples\" target=\"_blank\" rel=\"noopener\" aria-label=\"Use structured data markup in Microdata format to optimize images for SEO\">https:\/\/schema.org\/ImageObject<\/a><\/li>\n<\/ul>\n[\/vc_column_text][\/vc_column][vc_column column_padding=&#8221;no-extra-padding&#8221; column_padding_tablet=&#8221;inherit&#8221; column_padding_phone=&#8221;inherit&#8221; column_padding_position=&#8221;all&#8221; background_color_opacity=&#8221;1&#8243; background_hover_color_opacity=&#8221;1&#8243; column_shadow=&#8221;none&#8221; column_border_radius=&#8221;none&#8221; column_link_target=&#8221;_self&#8221; gradient_direction=&#8221;left_to_right&#8221; overlay_strength=&#8221;0.3&#8243; width=&#8221;1\/3&#8243; tablet_width_inherit=&#8221;default&#8221; tablet_text_alignment=&#8221;default&#8221; phone_text_alignment=&#8221;default&#8221; column_border_width=&#8221;none&#8221; column_border_style=&#8221;solid&#8221; bg_image_animation=&#8221;none&#8221;][image_with_animation image_url=&#8221;70&#8243; animation=&#8221;Fade In&#8221; hover_animation=&#8221;none&#8221; alignment=&#8221;&#8221; border_radius=&#8221;none&#8221; box_shadow=&#8221;none&#8221; image_loading=&#8221;lazy-load&#8221; max_width=&#8221;100%&#8221; max_width_mobile=&#8221;default&#8221;][\/vc_column][\/vc_row]\n","protected":false},"excerpt":{"rendered":"<p>[vc_row type=&#8221;in_container&#8221; full_screen_row_position=&#8221;middle&#8221; column_margin=&#8221;default&#8221; column_direction=&#8221;default&#8221; column_direction_tablet=&#8221;default&#8221; column_direction_phone=&#8221;default&#8221; scene_position=&#8221;center&#8221; text_color=&#8221;dark&#8221; text_align=&#8221;left&#8221; row_border_radius=&#8221;none&#8221; row_border_radius_applies=&#8221;bg&#8221; overlay_strength=&#8221;0.3&#8243; gradient_direction=&#8221;left_to_right&#8221; shape_divider_position=&#8221;bottom&#8221; bg_image_animation=&#8221;none&#8221;][vc_column column_padding=&#8221;no-extra-padding&#8221; column_padding_tablet=&#8221;inherit&#8221; column_padding_phone=&#8221;inherit&#8221; column_padding_position=&#8221;all&#8221; background_color_opacity=&#8221;1&#8243; background_hover_color_opacity=&#8221;1&#8243; column_shadow=&#8221;none&#8221; column_border_radius=&#8221;none&#8221; column_link_target=&#8221;_self&#8221; gradient_direction=&#8221;left_to_right&#8221; overlay_strength=&#8221;0.3&#8243; width=&#8221;2\/3&#8243; tablet_width_inherit=&#8221;default&#8221; tablet_text_alignment=&#8221;default&#8221;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":70,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[14,16],"class_list":{"0":"post-69","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-webdev","8":"tag-tech","9":"tag-webdev"},"_links":{"self":[{"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":0,"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/media\/70"}],"wp:attachment":[{"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dross.net\/alexander\/blog\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}