Skip to content

chore(fonts):⚡reduce font payload #1999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Skip if only .md files changed
id: file_check
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
echo "Changed files:"
echo "$CHANGED_FILES"

NON_MD_FILES=$(echo "$CHANGED_FILES" | grep -vE '\.md$' || true)

if [ -z "$NON_MD_FILES" ]; then
echo "Only .md files changed. Skipping job."
echo "skip_lighthouse=true" >> "$GITHUB_ENV"
else
echo "skip_lighthouse=false" >> "$GITHUB_ENV"
fi

- name: Exit early if skipped
if: env.skip_lighthouse == 'true'
run: echo "Skipping Lighthouse audit because only .md files changed." && exit 0
Copy link
Member

Choose a reason for hiding this comment

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

I’m not comfortable with this. pull_request_target has full permissions, and I don’t want to introduce vulnerabilities into this repository. I’m even thinking it might be better to handle the Lighthouse integration from Netlify.

Also, I feel that Lighthouse doesn’t provide very reliable data, in every PR I’ve seen it run, the results can be quite inaccurate, even when only a markdown file was changed.

Copy link
Member Author

@ShubhamOulkar ShubhamOulkar Aug 4, 2025

Choose a reason for hiding this comment

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

Also, I feel that Lighthouse doesn’t provide very reliable data, in every PR I’ve seen it run, the results can be quite inaccurate, even when only a markdown file was changed.

Our assets and website design logic causing this issue. I think we should get same result in netlify integration because netlify use lighthouse to generate results. ref

handle the Lighthouse integration from Netlify.

I support this and suggested before in my previous PR as well, we should consider netlify option just because we don't want unnecessary CI maintenance.

I don’t want to introduce vulnerabilities

That why I prefer pull_request action for simple task like lighthouse. But this action can not comment on PR's. By the way, there should not be a problem with security because I am using sha. I have seen #2031 this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm removing this workflow from this PR. Let's just keep this PR for fonts.

Copy link
Member Author

Choose a reason for hiding this comment

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

My latest commit got 100% results for desktop and on the edge for mobile. 😃


- name: Setup Node.js with npm cache
uses: actions/setup-node@v4
with:
Expand All @@ -33,12 +53,12 @@ jobs:
run: |
PREVIEW_URL="https://deploy-preview-${{ github.event.pull_request.number }}--expressjscom-preview.netlify.app"
echo "PREVIEW_URL=$PREVIEW_URL" >> "$GITHUB_ENV"
for i in {1..2}; do
for i in {1..4}; do
if curl -s --head "$PREVIEW_URL" | grep "200 OK" > /dev/null; then
echo "Preview is live!"
break
fi
echo "Waiting for Netlify to deploy... ($i/2)"
echo "Waiting for Netlify to deploy... ($i/4)"
sleep 10
done

Expand All @@ -64,6 +84,7 @@ jobs:

npx lighthouse "$url" \
$lighthouse_args \
--only-categories=performance,accessibility,best-practices \
--output json \
--output-path="lighthouse-report-${device}.json" \
--chrome-flags="--headless"
Expand Down Expand Up @@ -108,31 +129,32 @@ jobs:
script: |
const fs = require('fs');
const report = fs.readFileSync('lighthouse-report.md', 'utf8');

const { data: comments } = await github.rest.issues.listComments({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🚦Lighthouse Results')
comment.user.type === "Bot" &&
comment.body.includes("🚦 Lighthouse Results")
);

if (botComment) {
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
body: report,
});
console.log("Updated existing Lighthouse comment.");
} else {
await github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
body: report,
});
}

console.log("Created new Lighthouse comment.");
}
4 changes: 2 additions & 2 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
rel="preload"
href="/fonts/open-sans/woff2/OpenSans.woff2"
href="/fonts/open-sans/woff2/open-sans-latin-wght-normal.woff2"
as="font"
type="font/woff2"
crossorigin
/>
<link
rel="preload"
href="/fonts/open-sans/woff2/OpenSans-Italic.woff2"
href="/fonts/open-sans/woff2/open-sans-latin-wght-italic.woff2"
as="font"
type="font/woff2"
crossorigin
Expand Down
Binary file removed fonts/FontAwesome.otf
Binary file not shown.
Binary file removed fonts/fontawesome-webfont.eot
Binary file not shown.
520 changes: 0 additions & 520 deletions fonts/fontawesome-webfont.svg

This file was deleted.

Binary file removed fonts/fontawesome-webfont.ttf
Binary file not shown.
Binary file removed fonts/fontawesome-webfont.woff
Binary file not shown.
11 changes: 6 additions & 5 deletions fonts/open-sans/fonts.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 100 700;
font-weight: 300 800;
font-display: swap;
src: local("Open Sans"),
url("./woff2/OpenSans.woff2") format("woff2"),
url("./woff/OpenSans.woff") format("woff"),
url("./woff2/open-sans-latin-wght-normal.woff2") format("woff2-variations"),
url("./woff/OpenSans.woff") format("woff");
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 100 700;
font-weight: 300 800;
font-display: swap;
src: local("Open Sans"),
url("./woff2/OpenSans-Italic.woff2") format("woff2"),
url("./woff2/open-sans-latin-wght-italic.woff2") format("woff2-variations"),
url("./woff/OpenSans-Italic.woff") format("woff"),
}
Binary file removed fonts/open-sans/woff2/OpenSans-Italic.woff2
Binary file not shown.
Binary file removed fonts/open-sans/woff2/OpenSans.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const languageElement = document.getElementById('languageData');
const languagesData = languageElement ? JSON.parse(languageElement.dataset.languages) : [];
const langDisplay = document.getElementById('current-lang');
const i18nMsgBox = document.getElementById("i18n-notice-box");
const scrollToTopBtn = document.getElementById("top");

// display current language in language picker component
if (langDisplay) {
Expand Down