×
We - and our partners - use cookies to deliver our services and to show you ads based on your interests. By using our website, you agree to the use of cookies as described in our Cookie Policy.
Stimulated By Tyga 2015 • 1 SONG, 3:44
P L AY O N S P O T I F Y
1.
Stimulated
3:44
Slide 9
Wrong way of hiding <img src="example.png"> @media (max-width: 480px) { .img { display: none; } }
Slide 10
More wrong ways of hiding <body> <div class="section-1"> <p>This is the current section</p> <img src="example-1.png"> </div> <div class="section-2 hidden"> <p>This section might or might not be shown later</p> <img src="example-2.png"> </div> </body> .hidden { display: none; }
Slide 11
Optimising images
Slide 12
Slide 13
Slide 14
Best image format
Slide 15
Slide 16
Slide 17
Picture element and srcset
2 columns 1 column
3 columns
Alternative <div class="image-profile lazy-loaded-image" data-src-600="image-600.jpg" data-src-64="image-64.jpg"></div>
Not coupled with layout Choose image based on available sizes and <div>s area Decide when to request it
Slide 21
Combine regular images and lazy-loaded ones
Slide 22
How to lazy load: Basic approach For all images, check whether they are in the viewport (or close enough). If they are, request it. Repeat this onScroll and onResize
Slide 23
How to lazy load: IntersectionObserver FTW Don't bind to the scroll event. Subscribe to an event triggered when the image enters the rendered area Supported in Chrome, Opera. In development in Firefox and Edge. Very easy to use as another strategy in your lazy loading library.
Slide 24
IntersectionObserver
Slide 25
What to show while content is loading
Slide 26
Example
Slide 27
Slide 28
Alternatives
Slide 29
Examples of solid color
Slide 30
Slide 31
Slide 32
style="border:0"
Slide 33
Examples of Progressive Image Loading
Slide 34
Medium
Slide 35
How it's done
Render div Load small thumbnail Draw image to <canvas/> and apply blur effect Request large image Render large image and hide <canvas/>
Slide 36
Markup Overview
<figure> <div> <div/> <!-- this div keeps the aspect ratio so the placeholder doesn't collapse <img/> <!-- this is a tiny image with a resolution of e.g. ~27x17 and low quality <canvas/> <!-- takes the above image and applies a blur filter --> <img/> <!-- the large image to be displayed --> <noscript/> <!-- fallback for no JS --> </div> </figure>
How do users perceive it? Jason @lang
Follow
Did @Medium recently add a new image loading fadein? I noticed it this morning on mobile and just now again on web. Looks nice. 8:05 PM - 29 Feb 2016
DobaKung @zartre
Follow
@Medium's articles (although full of high-res images) load up very fast - 3:38 AM - 28 Mar 2015
Slide 39
or maybe not? Harris Rodis @harrisrodis
Follow
I don't know about you but I don't like a bit those blurry (still loading...) images on Medium. Very distracting. 5:40 PM - 29 Dec 2015
James Young @welcomebrand
Follow
That blurry image preloading thing on Medium - is it just me or does it make all images load extremely slowly now? 10:53 AM - 5 Feb 2016
When, as with the Progressive JPEG method, image rendition is a two-stage process in which an initially coarse image snaps into sharp focus, cognitive fluency is inhibited and the brain has to work slightly harder to make sense of what is being displayed. — From Progressive image rendering: Good or evil?
Slide 40
Reliable? Damien Erambert @Eramdam
Follow
I'm seeing this more and more on Medium posts. Maybe the whole "blur the pictures" stuff isn't a good idea… 7:44 PM - 8 Jan 2016
Sara Soueidan @SaraSoueidan
Follow
This @Medium page is fully loaded on my slow connection. Very pretty with those stupid image effects, isn’t it? 2:07 PM - 28 Nov 2015 3
19
Slide 41
What e ect does it have on RSS Readers and bots? Brad Dougherty @bdougherty
Follow
@Medium your weird blurry image thing means that when I read an article offline from my Safari Reading List, I don’t get any images 12:34 AM - 7 Nov 2015 1
Slide 42
Facebook
The technology behind preview photos
Slide 43
Facebook Unfortunately, the standard JPEG header is hundreds of bytes in size. In fact, the JPEG header alone is several times bigger than our entire 200-byte budget. However, excluding the JPEG header, the encoded data payload itself was approaching our 200 bytes.
Slide 44
Facebook Header (mainly Quantization Table and Huffman Table)
Compressed Data
Client (mobile app)
GraphQL
Slide 45
Generating tiny thumbnails JPG
464 B 532 B 428 B 409 B 456 B 692 B WebP
112 B
154 B
106 B
96 B
116 B
202 B
Slide 46
Generating tiny thumbnails JPG
464 B 532 B 428 B 409 B 456 B 692 B WebP
112 B
154 B
106 B
96 B
116 B
202 B