Skip to content

Commit 913f3a0

Browse files
authored
Merge pull request #468 from BeAPI/feat/lazysizes
feat (lazysizes): improves initial page load performance
2 parents 39f49b2 + 6931482 commit 913f3a0

File tree

8 files changed

+92
-3
lines changed

8 files changed

+92
-3
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<picture>
22
%%data-location%%
33
%%sources%%
4-
<img %%src%% fetchpriority="high" %%attributes%%>
4+
<img %%src%% fetchpriority="high" decoding="async" %%attributes%%>
55
</picture>
6-
<figcaption>%%caption%%</figcaption>
6+
<figcaption>%%caption%%</figcaption>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<picture>
22
%%data-location%%
33
%%sources%%
4-
<img %%src%% fetchpriority="high" %%attributes%%>
4+
<img %%src%% fetchpriority="high" decoding="async" %%attributes%%>
55
</picture>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"license": "GPL-2.0",
1818
"dependencies": {
1919
"@fontsource/poppins": "^5.0.5",
20+
"lazysizes": "^5.3.2",
2021
"oneloop.js": "^5.2.1"
2122
},
2223
"devDependencies": {

src/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'lazysizes'
12
import './classes/ScrollDirection'
23
import './classes/ButtonSeoClick'
34
import './classes/Header'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
@use "../01-abstract/variables" as *;
2+
@use "sass:math";
3+
4+
.lazyload,
5+
.lazyloading {
6+
background: $color-grey-200;
7+
opacity: 0;
8+
}
9+
10+
.lazyloaded {
11+
opacity: 1;
12+
transition: opacity .5s;
13+
}
14+
15+
// css loading for bgset items
16+
// with basicspinner
17+
$loading-dimensions: 50px;
18+
19+
[data-bgset] {
20+
position: relative;
21+
background-repeat: no-repeat;
22+
background-position: 50% 50%;
23+
background-size: cover;
24+
opacity: 1;
25+
26+
&::before {
27+
position: absolute;
28+
top: 0;
29+
right: 0;
30+
bottom: 0;
31+
left: 0;
32+
z-index: 2;
33+
content: "";
34+
background: $color-primary;
35+
transition: opacity .5s, z-index .5s ease .5s;
36+
}
37+
38+
&::after {
39+
position: absolute;
40+
top: calc(50% - #{math.div($loading-dimensions, 2)});
41+
left: calc(50% - #{math.div($loading-dimensions, 2)});
42+
z-index: 3;
43+
width: $loading-dimensions;
44+
height: $loading-dimensions;
45+
content: "";
46+
border: 5px solid $color-light;
47+
border-top-color: transparent;
48+
border-radius: $loading-dimensions;
49+
opacity: 1;
50+
transition: opacity .5s, z-index .5s ease .5s;
51+
transform: translateX(-50%) translateY(-50%);
52+
animation: loading .5s linear infinite;
53+
}
54+
55+
&.lazyload {
56+
opacity: 1;
57+
transition: opacity .5s;
58+
}
59+
60+
&.lazyloaded {
61+
&::after,
62+
&::before {
63+
z-index: -1;
64+
opacity: 0;
65+
}
66+
}
67+
}
68+
69+
@keyframes loading {
70+
0% {
71+
transform: rotate(0deg);
72+
}
73+
74+
100% {
75+
transform: rotate(360deg);
76+
}
77+
}

src/scss/editor.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ variables.$entry-file-name: "editor";
2727

2828
@use "04-utilities/wp-admin-bar";
2929
@use "04-utilities/focus";
30+
@use "04-utilities/lazyload";
3031
@use "04-utilities/seo";
3132
@use "04-utilities/video-wrapper";
3233
@use "04-utilities/palette";

src/scss/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ variables.$entry-file-name: "style";
3131

3232
@use "04-utilities/wp-admin-bar";
3333
@use "04-utilities/focus";
34+
@use "04-utilities/lazyload";
3435
@use "04-utilities/seo";
3536
@use "04-utilities/video-wrapper";
3637
@use "04-utilities/palette";

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,7 @@ __metadata:
22722272
imagemin-jpegtran: "npm:^7.0.0"
22732273
imagemin-optipng: "npm:^8.0.0"
22742274
imagemin-svgo: "npm:^10.0.1"
2275+
lazysizes: "npm:^5.3.2"
22752276
mini-css-extract-plugin: "npm:^1.5.0"
22762277
oneloop.js: "npm:^5.2.1"
22772278
postcss: "npm:^8.4.24"
@@ -6703,6 +6704,13 @@ __metadata:
67036704
languageName: node
67046705
linkType: hard
67056706

6707+
"lazysizes@npm:^5.3.2":
6708+
version: 5.3.2
6709+
resolution: "lazysizes@npm:5.3.2"
6710+
checksum: 10/15dfa1cc8bf8c3a4393014d411f161cb1df96ab0888a0776ba4dc34d45c6ba9c5d2b2eca22683c14dfeee552c67173cb9a512d640d3424d9910c0246e15c4edc
6711+
languageName: node
6712+
linkType: hard
6713+
67066714
"levn@npm:^0.4.1":
67076715
version: 0.4.1
67086716
resolution: "levn@npm:0.4.1"

0 commit comments

Comments
 (0)