Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

37 PNG files (up to 3.7MB each) were causing slow page loads. All images displayed at fixed CSS sizes (12em desktop, 6em mobile) but served at full resolution.

Changes

Image generation

  • Generated 76 optimized variants using ImageMagick:
    • 600px desktop versions (291-580KB, avg 400KB)
    • 300px mobile versions (75-144KB, avg 95KB)
  • Naming: image_600.png, image_300.png, image_grey_tabby_600.png, etc.
  • All mobile variants under 200KB
  • Original files retained

Code changes

  • Enhanced useThemeImage hook to detect screen width and serve appropriate variant:
    • <768px: 300px version
    • ≥768px: 600px version
    • Responds to window resize events
    • Maintains existing theme switching (light/dark)
// Hook now returns size and theme-appropriate path automatically
const imagePath = useThemeImage('sgex-mascot.png');
// → /sgex-mascot_300.png (mobile, light)
// → /sgex-mascot_grey_tabby_600.png (desktop, dark)

Tooling

  • scripts/generate-scaled-images.sh: Batch regeneration script for new images
  • IMAGE_OPTIMIZATION_GUIDE.md: Complete documentation with cross-platform instructions

Impact

DAK Dashboard with 9 component cards:

  • Before: ~14MB
  • After: ~900KB mobile (93% ↓), ~3.6MB desktop (74% ↓)

Sample reductions:

  • sgex-mascot.png: 3.7MB → 380KB/100KB (89-97% ↓)
  • authoring.png: 2.0MB → 564KB/132KB (72-93% ↓)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>add scaled card images</issue_title>
<issue_description>there are large file errors (see below examples).

These files are displayed at strict sizes (based on what is computed in the css layout). please create desktop and mobile scale versions of each of these large graphics. update the css to refer to proper scaled image. append image resolution to filename (before extension). retain original image. do this for all PNGs.

Example large files

  1. 3.68 MB sgex-mascot.png
    ⚠️ Large file (>200.0 KB)
  2. 3.68 MB pronunciation-guide.png
    ⚠️ Large file (>200.0 KB)
  3. 2.32 MB pronunciation-guide_grey_tabby.png
    ⚠️ Large file (>200.0 KB)
  4. 2.32 MB sgex-mascot_grey_tabby.png
    ⚠️ Large file (>200.0 KB)
  5. 2.10 MB authoring_grey_tabby.png
    ⚠️ Large file (>200.0 KB)
  6. 2.00 MB authoring.png
    ⚠️ Large file (>200.0 KB)
  7. 1.96 MB collaboration.png
    ⚠️ Large file (>200.0 KB)
  8. 1.80 MB dashboard/dak_interventions_grey_tabby.png
    ⚠️ Large file (>200.0 KB)
  9. 1.80 MB dashboard/dak_interventions.png
    ⚠️ Large file (>200.0 KB)
  10. 1.74 MB expirement.png
    ⚠️ Large file (>200.0 KB)
  11. 1.73 MB collaboration_grey_tabby.png
    ⚠️ Large file (>200.0 KB)
  12. 1.72 MB expirement_grey_tabby.png
    ⚠️ Large file (>200.0 KB)
  13. 1.39 MB pat-login_grey_tabby.png
    ⚠️ Large file (>200.0 KB)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 24, 2025 22:03
…ive loading

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
…-platform support

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Copilot AI changed the title [WIP] Add scaled versions of large card images Add responsive scaled image variants for large PNG assets Oct 24, 2025
Copilot AI requested a review from litlfred October 24, 2025 22:15
@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2025

🚀 Deployment Status: Successfully Deployed 🟢

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18793335120
Commit: a663f1e (view changes)
Workflow Step: Successfully Deployed

🌐 Preview URLs

Open Branch Preview

🔗 Quick Actions

Build Logs

📦 Build Artifacts Status

Artifact Status Description Type
workflow-event-log 🟢 Available GitHub event metadata with links .log
build-logs 🟢 Available Complete timestamped build output .txt
webpack-stats 🟢 Available Webpack compilation statistics .json
bundle-report 🟢 Available Bundle size analysis and recommendations .txt
build-step-log 🟢 Available Build step console output .log
bundle-analysis-step-log 🟢 Available Bundle analysis console output .log

🟢 All artifacts available! Click artifact names above or visit workflow artifacts section.

How to download:

  1. Click any artifact name in the table above
  2. Or visit the workflow run page and scroll to "Artifacts"
  3. Each artifact contains a single log file (no zip extraction needed)

📊 Overall Progress

Branch: copilot/add-scaled-card-images
Status: 🟢 Live and accessible
Status: Deployment complete - site is ready for testing


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2025

🔒 Dependency Security Check Results

✅ **No vulnerabilities found!**

All dependencies have been scanned and no security vulnerabilities were detected.

```
found 0 vulnerabilities
```

---

### ✅ Security Status: CLEAN
Your changes maintain the security posture of the project. Great job! 🎉

@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2025

🔍 Framework Compliance Report

Commit
Workflow
Compliance

Generated: 2025-10-25 12:26:12 UTC
Status: Action Required

📊 Summary

Status Count Percentage
🟢 Compliant 2/22 9%
🟠 Partial 20/22 91%
🔴 Non-compliant 0/22 0%

📦 Nested Layouts (4 components)


⚠️ Recommendations

Consider addressing partial compliance issues to improve code quality.

📚 Resources:

💡 This comment is automatically updated when compliance checks run.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2025

🔒 Security Check Report

Security Status

🟢 5 passed • 🟡 2 warnings

Security Checks

CheckStatusDetails
NPM Audit🟢No vulnerabilities found
Outdated Dependencies🟡8 outdated packages (1 major versions behind)
ESLint Security🟢No security-related linting issues
Security Headers🟡Some security headers missing in source
License Compliance🟢No problematic licenses detected
Secret Scanning🟢No potential secrets detected in code
Framework Compliance🟢Framework compliance checks passed

🔍 Action Items

⚠️ Outdated Dependencies - 8 outdated packages (1 major versions behind)

Details:
Major version updates needed for:

  • react-syntax-highlighter

Recommendation: Review outdated packages and update where possible

⚠️ Security Headers - Some security headers missing in source

Details:

Recommendation: Ensure all security headers are properly defined


⚠️ Security Status: WARNINGS

Some security warnings were detected. Please review the action items above.

Last checked: Sat, 25 Oct 2025 12:26:11 GMT


This security check is automatically run on every PR build. Learn more about our security checks

@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2025

🚀 Deployment Status: Successfully Deployed 🟢

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18793335307
Commit: a663f1e (view changes)
Workflow Step: Successfully Deployed

🌐 Preview URLs

Open Branch Preview

🔗 Quick Actions

Build Logs

📦 Build Artifacts Status

Artifact Status Description Type
workflow-event-log 🟢 Available GitHub event metadata with links .log
build-logs 🟢 Available Complete timestamped build output .txt
webpack-stats 🟢 Available Webpack compilation statistics .json
bundle-report 🟢 Available Bundle size analysis and recommendations .txt
build-step-log 🟢 Available Build step console output .log
bundle-analysis-step-log 🟢 Available Bundle analysis console output .log

🟢 All artifacts available! Click artifact names above or visit workflow artifacts section.

How to download:

  1. Click any artifact name in the table above
  2. Or visit the workflow run page and scroll to "Artifacts"
  3. Each artifact contains a single log file (no zip extraction needed)

📊 Overall Progress

Branch: copilot/add-scaled-card-images
Status: 🟢 Live and accessible
Status: Deployment complete - site is ready for testing


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@litlfred litlfred marked this pull request as ready for review October 25, 2025 12:44
Copilot AI review requested due to automatic review settings October 25, 2025 12:44
@litlfred litlfred merged commit d8288af into main Oct 25, 2025
12 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements responsive image optimization for 37 large PNG assets (up to 3.7MB each) that were causing slow page loads. The solution generates scaled variants (600px desktop, 300px mobile) and automatically serves the appropriate version based on screen size and theme, achieving 93% bandwidth reduction on mobile and 74% on desktop.

Key changes:

  • Enhanced useThemeImage hook to detect screen width and serve size-appropriate variants with automatic resize handling
  • Created batch generation script (generate-scaled-images.sh) producing 76 optimized image variants
  • Added comprehensive documentation guide covering regeneration procedures and performance metrics

Reviewed Changes

Copilot reviewed 3 out of 79 changed files in this pull request and generated 3 comments.

File Description
src/hooks/useThemeImage.js Added screen width detection, resize listener, and logic to serve 300px or 600px variants based on viewport size while maintaining theme switching
scripts/generate-scaled-images.sh New bash script that generates scaled PNG variants using ImageMagick with size reporting and error handling
IMAGE_OPTIMIZATION_GUIDE.md Complete documentation covering naming conventions, regeneration procedures, performance metrics, and troubleshooting guidance

Comment on lines +78 to +81
const handleResize = () => {
updateImagePath();
};
window.addEventListener('resize', handleResize);
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resize event listener triggers on every resize event, which can fire hundreds of times during a single resize action. Consider debouncing or throttling this handler to reduce unnecessary image path recalculations and improve performance.

Copilot uses AI. Check for mistakes.
errors=0

# Find all PNG files larger than 200KB and store in array
mapfile -t png_files < <(find public -name "*.png" -size +200k -type f | sort)
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapfile builtin is a Bash 4+ feature that may not be available on older systems or in scripts using #!/bin/sh. Consider using a more portable approach like while read for better compatibility, or ensure the shebang explicitly requires bash.

Suggested change
mapfile -t png_files < <(find public -name "*.png" -size +200k -type f | sort)
png_files=()
while IFS= read -r file; do
png_files+=("$file")
done < <(find public -name "*.png" -size +200k -type f | sort)

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +163
- **Mobile (3G)**: ~85 seconds → ~6 seconds (93% faster)
- **Desktop (Cable)**: ~3 seconds → ~0.8 seconds (73% faster)
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The percentage calculation appears incorrect. The time reduction from 85s to 6s is approximately 93% reduction in time, not 93% faster. "93% faster" would mean the new time is 7% of the improvement, which doesn't match these numbers. Consider using "93% reduction in loading time" or "14x faster" for clarity.

Suggested change
- **Mobile (3G)**: ~85 seconds → ~6 seconds (93% faster)
- **Desktop (Cable)**: ~3 seconds → ~0.8 seconds (73% faster)
- **Mobile (3G)**: ~85 seconds → ~6 seconds (93% reduction in loading time, ~14x faster)
- **Desktop (Cable)**: ~3 seconds → ~0.8 seconds (73% reduction in loading time, ~3.75x faster)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add scaled card images

2 participants