-
Notifications
You must be signed in to change notification settings - Fork 73
Optimize Site Loading #1439
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
Optimize Site Loading #1439
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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 comprehensive site loading optimizations, improving GTMetrix Grade from D to C by introducing several performance enhancements: font optimization with local WOFF2 formats, lazy loading for Flow Runner components, caching headers, and reduced bundle sizes.
- Switched from remote to local WOFF2 fonts with TTF fallbacks for better compression and performance
- Implemented lazy loading for Flow Runner iframe until mouseover to reduce initial load time
- Added comprehensive caching headers for static assets in Vercel configuration
Reviewed Changes
Copilot reviewed 16 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
vercel.json | Added comprehensive caching headers for static assets |
src/plugins/font-preload.js | New plugin for preloading critical fonts in WOFF2 format |
src/hooks/use-icons.ts | Refactored to use static paths instead of dynamic imports |
src/components/Icon.tsx | Simplified to always render as images with static paths |
src/ui/design-system/src/lib/Pages/HomePage/QuickStartShowcase.tsx | Added lazy loading for Flow Runner with fallback UI |
static/css/* | Added optimized CSS files for KaTeX and codicon fonts |
src/ui/design-system/styles/fonts.css | Removed duplicate Inter font declarations, added font-display: swap |
docusaurus.config.js | Updated to use local fonts and CSS instead of remote resources |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/ui/design-system/src/lib/Pages/HomePage/QuickStartShowcase.tsx
Outdated
Show resolved
Hide resolved
@@ -26,6 +26,7 @@ | |||
"@docusaurus/preset-classic": "^3.5.2", | |||
"@docusaurus/types": "^3.5.2", | |||
"@floating-ui/react-dom": "1.3.0", | |||
"@fluentui/react": "^8.123.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the new icon set? Should we remove the old and swap it out with this one so there are not two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That has the specific microsoft icons for the fake flowrunner. Happy to do it another way if that's better!
import { Icon, initializeIcons } from '@fluentui/react'; | ||
|
||
// Initialize Fluent UI icons | ||
initializeIcons(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be done on an app layout page at some shared level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno! But I don't think those icons will be used outside of this component anytime in the near future.
src/ui/design-system/src/lib/Pages/HomePage/QuickStartShowcase.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/hooks/use-icons.ts
Outdated
import RandomIcon from '@site/static/images/icons/random.svg'; | ||
import FaucetIcon from '@site/static/images/icons/Faucet.svg'; | ||
// Static icon paths - more reliable than dynamic imports | ||
const getIconPath = (name: IconName): string | null => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just have an object map? Is there a point to the function loading it into the map? Feels redundant.
const iconMap: Record<IconName, string> = {
[IconName.GETTING_STARTED]: '/images/icons/getting-started.svg',
[IconName.WHY_FLOW]: '/images/icons/why-flow.svg',
[IconName.HELLO_WORLD]: '/images/icons/hello-world.svg',
[IconName.FLOW_CADENCE]: '/images/icons/flow-cadence.svg',
[IconName.EVM_ON_FLOW]: '/images/icons/evm-on-flow.svg',
[IconName.RANDOM]: '/images/icons/random.svg',
[IconName.BATCHED_EVM_TRANSACTIONS]: '/images/icons/batched-evm-transactions.svg',
// ... rest of them
};
src/hooks/use-icons.ts
Outdated
'uniblock': '/img/ecosystem/uniblock.svg', | ||
}), []); | ||
return useMemo(() => { | ||
const loadIcon = (name: IconName) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then if you have the map do you even need this?
src/hooks/use-icons.ts
Outdated
'uniblock': '/img/ecosystem/uniblock.svg', | ||
}), []); | ||
return { | ||
getIcon: (name: IconName): string | null => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using this?
src/components/Icon.tsx
Outdated
</div> | ||
); | ||
// Get icon path | ||
const iconPath = icons.loadIcon(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this exist?
Improves GTMetrix Grade from D to C (possibly even more once the vercel overhead isn't present)
Simulates Flow Runner until mouseover to save on loading
Font is now local instead of remote
Font is now wolff2 instead of otf
Removed several duplicate loads of Inter
Removed unused svgs