Optimize render-blocking CSS to improve PageSpeed performance #1459
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Optimize render-blocking CSS to improve PageSpeed performance
Summary
This PR implements CSS loading optimizations to address PageSpeed Insights recommendations for reducing render-blocking resources on alchemy.com/docs (PageSpeed score: 28/100 mobile, 49/100 desktop).
Changes:
css-optimization.js): Adds resource hints (preconnect, dns-prefetch) for critical domains, attempts to preload CSS files, and applies font-display: swap to fontscss-performance-optimization.css): Defines font-display: swap for GT-Planar font family and adds CSS containment optimizationsbeforeInteractivestrategy for early execution, and includes the new CSS file before existing stylesIntended impact: Reduce render-blocking CSS time (~300ms according to PageSpeed Insights), improve FCP/LCP metrics, and provide better font loading experience.
Review & Testing Checklist for Human
Test PageSpeed Insights score - Run alchemy.com/docs through PageSpeed Insights to verify actual performance improvement. The changes may provide only marginal improvements since the core render-blocking CSS comes from Fern's platform (prod.ferndocs.com) which cannot be directly modified.
Verify font loading behavior - Check that GT-Planar fonts still load correctly across the site. Note: The @font-face rules in css-performance-optimization.css are incomplete (missing
srcproperty) and may not actually apply font-display: swap. You may see FOUT (Flash of Unstyled Text) if this works.Check browser console for errors - The JavaScript manipulates DOM and attempts to modify stylesheets, which may throw CORS errors for cross-origin resources. Test in Chrome DevTools console.
Test visual regression - Verify no layout shifts, font rendering issues, or broken styling. The
contain: layout styleCSS property on.fern-page-contentcould cause unexpected layout behavior.Cross-browser testing - Test in Safari and Firefox, as CSS containment and font-display support varies by browser.
Recommended test plan:
Notes
da16fe04eff9fb39.cssand80bca615e6d01b34.cssfrom prod.ferndocs.com), which cannot be directly modified from this repository. These changes work around the limitation by adding optimizations at the documentation configuration level.srcproperties. Consider revising or removing this file if font-display isn't being applied.<head>.Session: https://app.devin.ai/sessions/45e9acd559974760b875ff0d9f6f0721
Requested by: Deep Singhvi ([email protected]) (@dsinghvi)