Skip to content

Add per-page asset size analysis with PR comment reporting#40

Open
srungta with Copilot wants to merge 2 commits into
mainfrom
copilot/analyze-site-asset-statistics
Open

Add per-page asset size analysis with PR comment reporting#40
srungta with Copilot wants to merge 2 commits into
mainfrom
copilot/analyze-site-asset-statistics

Conversation

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown

On every PR, post (and update) a comment reporting the total download weight of each page in the built site — HTML + CSS + JS + images — sorted by decreasing size, with a collapsible per-asset breakdown.

New: scripts/analyze-page-sizes.mjs

  • Walks _site/**/*.html; extracts locally-referenced assets from <link href>, <script src>, <img src>, and <source srcset/src> via regex (no external deps)
  • Classifies assets by type (html, css, js, image, font, other), resolves paths against _site, sums weights per page
  • Outputs a Markdown summary table sorted by total descending + a <details> block with the full per-asset breakdown
  • Accepts --site <path> override; exits with a clear message if _site is missing

Example PR comment output:

## 📦 Page Asset Size Report

Analyzed 24 pages — sorted by total download weight (HTML + CSS + JS + images).

| Page | Total | HTML | CSS | JS | Images |
|------|------:|-----:|----:|---:|-------:|
| `/p/intro-to-redis/` | **312.4 KB** | 18.2 KB | 12.1 KB | 4.1 KB | 278.0 KB |
| `/` | **45.3 KB** | 8.4 KB | 12.1 KB | 4.1 KB | 20.7 KB |
...

New: .github/workflows/page-asset-sizes.yml

  • Triggers on pull_request (opened, synchronize, reopened)
  • Installs jekyll 3.9.0 + kramdown-parser-gfm 1.1.0 (matches Dockerfile), runs jekyll build, then the analysis script
  • Uses peter-evans/find-comment + peter-evans/create-or-update-comment to create-or-replace a single comment per PR

Updated: dev.sh

  • Adds ./dev.sh page-sizes [--site <path>] for local runs after jekyll build

Copilot AI linked an issue Jul 26, 2026 that may be closed by this pull request
- scripts/analyze-page-sizes.mjs: walks _site HTML pages, extracts
  local asset references (CSS, JS, images), sums per-page weights, and
  emits a Markdown report sorted by decreasing total size with a
  collapsible detailed breakdown.
- .github/workflows/page-asset-sizes.yml: PR workflow that builds the
  Jekyll site, runs the analysis, and posts/updates a PR comment.
- dev.sh: adds `page-sizes` command to run the script locally.

Closes #39
Copilot AI changed the title [WIP] Add page size analysis in PR builds Add per-page asset size analysis with PR comment reporting Jul 26, 2026
Copilot AI requested a review from srungta July 26, 2026 17:41
@srungta
srungta requested a review from Copilot July 26, 2026 17:48
@srungta
srungta marked this pull request as ready for review July 26, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds automated per-page asset weight reporting for this Jekyll blog, producing a Markdown summary (and per-page breakdown) of built _site page sizes and posting/updating it as a PR comment.

Changes:

  • Added scripts/analyze-page-sizes.mjs to scan built HTML pages, resolve locally referenced assets, and output a Markdown report sorted by total size.
  • Added a GitHub Actions workflow to build the site on PRs and post/update a single “Page Asset Size Report” comment.
  • Extended dev.sh with a page-sizes command for local runs.

Reviewed changes

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

File Description
scripts/analyze-page-sizes.mjs New Node script to compute per-page size totals and emit a Markdown report.
dev.sh Adds a page-sizes helper command and completion support.
.github/workflows/page-asset-sizes.yml New workflow to build Jekyll on PRs and post/update the report comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +71 to +75
// <link href="..."> — stylesheets and preloads
for (const m of html.matchAll(/<link\s[^>]*\bhref=["']([^"']+)["'][^>]*>/gi)) {
const u = cleanUrl(m[1]);
if (isLocal(u)) urls.add(u);
}
Comment on lines +7 to +10
permissions:
contents: read
pull-requests: write

Comment on lines +10 to +11

jobs:
Comment on lines +3 to +6
on:
pull_request:
types: [opened, synchronize, reopened]

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.

Analyse site asset statistic by page at build

3 participants