Skip to content

Commit

Permalink
Documentation and resoning
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeSimoes committed Jan 2, 2024
1 parent 500e86e commit b60d037
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export const debounce = (func, wait, immediate) => {
export const eagerImage = (block, length = 1) => {
const imgs = Array.from(block.querySelectorAll('img')).slice(0, length);
imgs.forEach((img) => {
const width = img.getAttribute('width');
const height = img.getAttribute('height');
const ratio = Math.floor((width / height) * 10) / 10;
img.style.aspectRatio = ratio;
img.setAttribute('loading', 'eager');
document.head.append(`<link rel="preload" as="image" href="${img.src}">`);
});
Expand Down
4 changes: 4 additions & 0 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
}
}

img {
object-fit: cover;
}

body {
display: none;
background-color: var(--scope-background, #fff);
Expand Down

0 comments on commit b60d037

Please sign in to comment.