Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 39427fe

Browse files
authored
Merge pull request #14 from chicio/prevent-reflow 🚀
Prevent content reflow with <img/> lazy loading 🚀
2 parents 39e6ad4 + cd6cfd2 commit 39427fe

File tree

83 files changed

+320
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+320
-345
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Change Log
22
All changes to Chicio coding will be documented in this file.
33

4+
## [1.6.0](https://github.com/chicio/chicio.github.io/releases/tag/1.6.0)
5+
Release date: 2019-05-02.
6+
7+
#### Added
8+
9+
- Added svg placeholder to prevent content reflow for lazy loaded images
10+
- Updated gems
11+
412
## [1.5.0](https://github.com/chicio/chicio.github.io/releases/tag/1.5.0)
513
Release date: 2019-04-05.
614

Gemfile.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (4.2.10)
4+
activesupport (4.2.11.1)
55
i18n (~> 0.7)
66
minitest (~> 5.1)
77
thread_safe (~> 0.3, >= 0.3.4)
88
tzinfo (~> 1.1)
9-
addressable (2.5.2)
9+
addressable (2.6.0)
1010
public_suffix (>= 2.0.2, < 4.0)
1111
coffee-script (2.4.1)
1212
coffee-script-source
@@ -16,7 +16,7 @@ GEM
1616
colorize (0.8.1)
1717
commonmarker (0.17.13)
1818
ruby-enum (~> 0.5)
19-
concurrent-ruby (1.1.4)
19+
concurrent-ruby (1.1.5)
2020
dnsruby (1.61.2)
2121
addressable (~> 2.5)
2222
em-websocket (0.5.1)
@@ -30,11 +30,11 @@ GEM
3030
multipart-post (>= 1.2, < 3)
3131
ffi (1.10.0)
3232
forwardable-extended (2.6.0)
33-
gemoji (3.0.0)
34-
github-pages (197)
35-
activesupport (= 4.2.10)
33+
gemoji (3.0.1)
34+
github-pages (198)
35+
activesupport (= 4.2.11.1)
3636
github-pages-health-check (= 1.16.1)
37-
jekyll (= 3.7.4)
37+
jekyll (= 3.8.5)
3838
jekyll-avatar (= 0.6.0)
3939
jekyll-coffeescript (= 1.1.1)
4040
jekyll-commonmark-ghpages (= 0.1.5)
@@ -82,7 +82,7 @@ GEM
8282
octokit (~> 4.0)
8383
public_suffix (~> 3.0)
8484
typhoeus (~> 1.3)
85-
html-pipeline (2.10.0)
85+
html-pipeline (2.11.0)
8686
activesupport (>= 2)
8787
nokogiri (>= 1.4)
8888
html-proofer (3.10.2)
@@ -97,7 +97,7 @@ GEM
9797
http_parser.rb (0.6.0)
9898
i18n (0.9.5)
9999
concurrent-ruby (~> 1.0)
100-
jekyll (3.7.4)
100+
jekyll (3.8.5)
101101
addressable (~> 2.4)
102102
colorator (~> 1.0)
103103
em-websocket (~> 0.5)
@@ -115,9 +115,9 @@ GEM
115115
jekyll-coffeescript (1.1.1)
116116
coffee-script (~> 2.2)
117117
coffee-script-source (~> 1.11.1)
118-
jekyll-commonmark (1.2.0)
118+
jekyll-commonmark (1.3.1)
119119
commonmarker (~> 0.14)
120-
jekyll (>= 3.0, < 4.0)
120+
jekyll (>= 3.7, < 5.0)
121121
jekyll-commonmark-ghpages (0.1.5)
122122
commonmarker (~> 0.17.6)
123123
jekyll-commonmark (~> 1)
@@ -195,7 +195,7 @@ GEM
195195
jekyll-seo-tag (~> 2.0)
196196
jekyll-titles-from-headings (0.5.1)
197197
jekyll (~> 3.3)
198-
jekyll-watch (2.1.2)
198+
jekyll-watch (2.2.1)
199199
listen (~> 3.0)
200200
jemoji (0.10.2)
201201
gemoji (~> 3.0)
@@ -215,11 +215,11 @@ GEM
215215
jekyll-seo-tag (~> 2.1)
216216
minitest (5.11.3)
217217
multipart-post (2.0.0)
218-
nokogiri (1.10.1)
218+
nokogiri (1.10.3)
219219
mini_portile2 (~> 2.4.0)
220-
octokit (4.13.0)
220+
octokit (4.14.0)
221221
sawyer (~> 0.8.0, >= 0.5.3)
222-
parallel (1.14.0)
222+
parallel (1.17.0)
223223
pathutil (0.16.2)
224224
forwardable-extended (~> 2.6)
225225
public_suffix (3.0.3)
@@ -232,14 +232,14 @@ GEM
232232
ruby_dep (1.5.0)
233233
rubyzip (1.2.2)
234234
safe_yaml (1.0.5)
235-
sass (3.7.3)
235+
sass (3.7.4)
236236
sass-listen (~> 4.0.0)
237237
sass-listen (4.0.0)
238238
rb-fsevent (~> 0.9, >= 0.9.4)
239239
rb-inotify (~> 0.9, >= 0.9.7)
240-
sawyer (0.8.1)
241-
addressable (>= 2.3.5, < 2.6)
242-
faraday (~> 0.8, < 1.0)
240+
sawyer (0.8.2)
241+
addressable (>= 2.3.5)
242+
faraday (> 0.8, < 2.0)
243243
terminal-table (1.8.0)
244244
unicode-display_width (~> 1.1, >= 1.1.1)
245245
thread_safe (0.3.6)
@@ -248,7 +248,7 @@ GEM
248248
tzinfo (1.2.5)
249249
thread_safe (~> 0.1)
250250
unicode-display_width (1.5.0)
251-
yell (2.0.7)
251+
yell (2.1.0)
252252

253253
PLATFORMS
254254
ruby

_css/main.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ canvas {
3737
background-color: $primary-color;
3838
}
3939

40+
.lazy {
41+
background-color: $divider-color;
42+
}
43+
4044
@mixin keyframes($animationName) {
4145
@-webkit-keyframes #{$animationName} {
4246
@content;
@@ -55,10 +59,6 @@ canvas {
5559
}
5660
}
5761

58-
.lazy {
59-
visibility: hidden;
60-
}
61-
6262
.break {
6363
display: inline
6464
}
@@ -337,6 +337,7 @@ footer {
337337
box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.375);
338338
border-radius: 3px;
339339
border: 1px solid #d4d4d4;
340+
width: 100%;
340341
}
341342

342343
.project-info {

_drafts/2019-05-10-intersection-observer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ authors: [fabrizio_duroni]
1818
In the last few months I worked hard to improved the page speed of my website (yeah, the one you're visiting right now). I improved all my client side code in order to be able to reach a performance score above 90 points on [Lighthouse](https://developers.google.com/web/tools/lighthouse/), the offical Google Chrome tool to measure performance, accessibility, progressive web apps compliance and more on your web application.
1919
One of the last thing that was contained in the report was a warning about offscreen images, like the one contained in the following screenshot:
2020

21-
{% include blog-lazy-image.html description="intersection observer offscreen audit" src="/assets/images/posts/intersection-observer-offscreen-audit.jpg" %}
21+
{% include blog-lazy-image.html description="intersection observer offscreen audit" width="1518" height="193" src="/assets/images/posts/intersection-observer-offscreen-audit.jpg" %}
2222

2323
So I followed the link contained in the report that points to a page where are contained the [official Google Guidelines about loading offscreen images](https://developers.google.com/web/tools/lighthouse/audits/offscreen-images). The main topic of the page is the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) and how it can help you to load specific content only when it becomes visible in the viewport. I found also anothe article on the official Google developer website that explains in details how to leverage the power of Intersection Observer to lazy load the images in your web applications. So as you may imagine I "accepted the challenge" (like only [Barney Stinson](https://en.wikipedia.org/wiki/Barney_Stinson) in how I met your mother is used to do :stuck_out_tongue_winking_eye:) and I started to implement the lazy load of images for my website.
2424

_drafts/2019-06-15-google-play-store-publish-pwa.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ So as you can read above, a Trusted Web Activity let you integrate web content t
3636

3737
Let's start to see the real action: how I publish my blog PWA to the Google Play Store using TWA. First of all, I created a nw android project. This was a standard Android project with minimum API level 16. This let me cover the 99.6% of the Android user base. I choosed to create an empty project without any activity/fragment in it.
3838

39-
{% include blog-lazy-image.html description="pwa app create project" src="/assets/images/posts/pwa-app-01-create-project.png" %}
39+
{% include blog-lazy-image.html description="pwa app create project" width="1500" height="1236" src="/assets/images/posts/pwa-app-01-create-project.jpg" %}
4040

4141
Then I added the TWA support as a dependecy of the app. The TWA implementation is contained inside the custom tabs client library published on [Jitpack](https://jitpack.io/ "Jitpack") (because unfortunately at the moment of this writing the custom tabs client library contained inside Jetpack doesn't have the TWA support). So I added Jitpack as repository to the project level gradle file. Then I added the custom tabs client library as dependecy inside the module gradle file. This last dependecy points to the custom tabs client library published on github and exposed through Jitpack. I had also to specify a specific commit hash in order to be sure that the library version downloaded contains the TWA support.
4242

43-
{% include blog-lazy-image.html description="pwa app jitpack" src="/assets/images/posts/pwa-app-02-jitpack-configuration.png" %}
44-
{% include blog-lazy-image.html description="pwa app custom tab library" src="/assets/images/posts/pwa-app-03-java8-and-custom-tab-dependecies.png" %}
43+
{% include blog-lazy-image.html description="pwa app jitpack" width="1500" height="889" src="/assets/images/posts/pwa-app-02-jitpack-configuration.jpg" %}
44+
{% include blog-lazy-image.html description="pwa app custom tab library" width="1500" height="889" src="/assets/images/posts/pwa-app-03-java8-and-custom-tab-dependecies.jpg" %}
4545

4646
After the depencies setup I added the TWA Activity. To do this I just had to modify the Android app manifest file by declaring a new TWA activity inside it. For the readers that are not mobile developer, the Android app manifest is a file contained in all the Android apps. Its main function is to present essential information about the application to the Android system including:
4747

@@ -55,7 +55,7 @@ The declaration of the TWA inside the Android app manifest must include some imp
5555
* an `intent-filter` that adds the TWA to the Android Launcher
5656
* another `intent-filter` that allows the TWA to intercept Android Intents that open https://airhorner.com. The `android:host` attribute inside the data tag must point to the domain being opened by the TWA and specified in the `meta-data` tag.
5757

58-
{% include blog-lazy-image.html description="pwa app twa declaration" src="/assets/images/posts/pwa-app-04-twa-activity-declaration.png" %}
58+
{% include blog-lazy-image.html description="pwa app twa declaration" width="1500" height="889" src="/assets/images/posts/pwa-app-04-twa-activity-declaration.jpg" %}
5959

6060
Now I had to establish the link between our PWA website and our PWA app. This is a two way operation because I had to:
6161

@@ -79,11 +79,11 @@ Let's start from the first association, from the app to the web site. To do this
7979
</resources>
8080
```
8181

82-
{% include blog-lazy-image.html description="pwa app Digital AssetLink statement" src="/assets/images/posts/pwa-app-05-associate-app-to-web-1.png" %}
82+
{% include blog-lazy-image.html description="pwa app Digital AssetLink statement" width="1500" height="889" src="/assets/images/posts/pwa-app-05-associate-app-to-web-1.jpg" %}
8383

8484
Then I linked this string resource statement inside the Android app manifest by adding a new `meta-data` tag as a child of the `application` tag (NOT inside the TWA declaration).
8585

86-
{% include blog-lazy-image.html description="pwa app Digital AssetLink statement manifest" src="/assets/images/posts/pwa-app-05-associate-app-to-web-2.png" %}
86+
{% include blog-lazy-image.html description="pwa app Digital AssetLink statement manifest" width="1500" height="889" src="/assets/images/posts/pwa-app-05-associate-app-to-web-2.jpg" %}
8787

8888
It is possible to test that the association from app to the website has been completed. To do this I had to:
8989

@@ -108,7 +108,7 @@ keytool -list -v -keystore <your keystore jks file> -alias <your alias> -storepa
108108

109109
With both pieces of information at hand I was able to generate a web `assetlink.json` statement using the [assetlinks generator](https://developers.google.com/digital-asset-links/tools/generator). The `assetlink.json` generated must be served from the PWA domain from the URL `<your PWA domain>/.well-known/assetlinks.json`.
110110

111-
{% include blog-lazy-image.html description="pwa app Digital AssetLink generator" src="/assets/images/posts/pwa-app-07-assetlink-generator.png" %}
111+
{% include blog-lazy-image.html description="pwa app Digital AssetLink generator" width="1500" height="888" src="/assets/images/posts/pwa-app-07-assetlink-generator.jpg" %}
112112

113113
After publishing the `assetlink.json` to my PWA domain my app was ready to be published to the store. So I followed the standard procedure [to upload an app to the Google Play Store](https://developer.android.com/studio/publish/upload-bundle).
114114
If the two ways association fails, it is possible to check for error messages using the the Android Debug Bridge, by launching from the terminal the following command with the test device connected (or the emulator running).
-51.1 KB
Loading
-10.8 KB
Loading
135 KB
Loading
169 KB
Loading
206 KB
Loading

0 commit comments

Comments
 (0)