From 3c5a8625f8f13d6442a737eac4c37aa398848e7d Mon Sep 17 00:00:00 2001 From: valleballe Date: Mon, 14 Oct 2024 15:25:54 -0400 Subject: [PATCH] Public only and lazy image loading --- script.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index c025a2d..44deee5 100644 --- a/script.js +++ b/script.js @@ -19,6 +19,7 @@ document.addEventListener('DOMContentLoaded', () => { let startYear = new Date(project.start_on).getFullYear(); if (startYear < 1985){ startYear = new Date(project.created).getFullYear(); + project.start_on = project.created; } return isNaN(startYear) ? null : startYear; }).filter(year => year !== null))]; @@ -64,8 +65,9 @@ document.addEventListener('DOMContentLoaded', () => { projectGrid.innerHTML = ''; projects.forEach(project => { const startYear = new Date(project.start_on).getFullYear(); + const visibility = project.visibility; - if (startYear === year) { + if (startYear === year && visibility=="PUBLIC") { const projectContainer = document.createElement('div'); projectContainer.classList.add('project-container'); const imgURL = project.hero_image_url; @@ -74,6 +76,7 @@ document.addEventListener('DOMContentLoaded', () => { const img = document.createElement('img'); img.src = imgURL; img.alt = project.title; + img.loading="lazy"; projectContainer.appendChild(img); } else { const grayValue = Math.floor(Math.random() * 256);