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

Conversation

ShubhamOulkar
Copy link
Member

@ShubhamOulkar ShubhamOulkar commented Aug 2, 2025

page load time reduced by ~300-400ms

express.com preview
expressjs com tree a tree
expressjs com perf a

~230-270 kB reduction in font payload

new font files old font files
Screenshot 2025-08-02 190411 image

Font source: https://github.com/fontsource/font-files/tree/main/fonts/variable/open-sans/files

@ShubhamOulkar ShubhamOulkar requested a review from a team as a code owner August 2, 2025 13:30
Copy link

netlify bot commented Aug 2, 2025

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 181f784
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6891722459bf160008eded24
😎 Deploy Preview https://deploy-preview-1999--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

github-actions bot commented Aug 2, 2025

🚦 Lighthouse Results (Mobile & Desktop)

URL Device Perf A11y Best Practices
/ mobile 🟠 80 🟢 100 🟢 96
/en/blog/posts.html mobile 🟢 96 🟢 96 🟢 96
/en/5x/api.html mobile 🔴 73 🟢 95 🟢 96
/ desktop 🟢 98 🟢 100 🟢 96
/en/blog/posts.html desktop 🟢 100 🟢 96 🟢 93
/en/5x/api.html desktop 🟢 100 🟢 95 🟢 96

@ShubhamOulkar ShubhamOulkar changed the title chore(fonts):⚡Improve website performance [WIP] chore(fonts):⚡Improve website performance Aug 2, 2025
@ShubhamOulkar
Copy link
Member Author

ShubhamOulkar commented Aug 2, 2025

🚦 Lighthouse Results (Mobile & Desktop)

Need to remove spaces to edit comment correctly. Also need to increase wait time for Netlify preview.

Happy 😃 mobile results are improving.

@ShubhamOulkar ShubhamOulkar changed the title [WIP] chore(fonts):⚡Improve website performance chore(fonts):⚡reduce font payload Aug 3, 2025
@ShubhamOulkar
Copy link
Member Author

I just realized that for improving performance on mobile needs refactoring in logic and assets file. It should be good to do it in other PR.

Copy link
Member

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

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

We need to know where you got the fonts before accepting this PR.

Comment on lines 23 to 41
- 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. 😃

@ShubhamOulkar
Copy link
Member Author

ShubhamOulkar commented Aug 4, 2025

We need to know where you got the fonts before accepting this PR.

@bjohansebas, I got this woff2 fonts from https://github.com/fontsource/font-files/tree/main/fonts/variable/open-sans/files

@expressjs expressjs deleted a comment from github-actions bot Aug 4, 2025
@expressjs expressjs deleted a comment from github-actions bot Aug 4, 2025
@expressjs expressjs deleted a comment from github-actions bot Aug 4, 2025
@Phillip9587
Copy link
Contributor

Fontsource provides npm packages for the fonts: https://fontsource.org/fonts/open-sans/install

@ShubhamOulkar
Copy link
Member Author

Fontsource provides npm packages for the fonts: https://fontsource.org/fonts/open-sans/install

Hi @Phillip9587, we don't use any bundler in this project so that we can not use this. See Prerequisites section. Fontsource provide CDN option, but I prefer self-hosting fonts. Tell me if I am missing something because you're suggesting this second time I guess.

Copy link
Member Author

@ShubhamOulkar ShubhamOulkar left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Please, whoever reviews it, merge it as soon as possible since it improves user experience for slower Internet connections.

@ShubhamOulkar ShubhamOulkar requested a review from crandmck August 7, 2025 02:53
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.

3 participants