-
-
Notifications
You must be signed in to change notification settings - Fork 254
Preload assets across websites (#11334) #11335
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
Conversation
WalkthroughIntroduces a new global flag enableCacheControl (false) in multiple service-worker.published.js files. Updates several App.razor files to use capitalized Link/Script attributes (Href/Src) and adds two preload hints for _framework/dotnet.js and _framework/blazor.boot.json. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User Agent (Browser)
participant Doc as App.razor (Head)
participant FW as Blazor Framework
Note over Doc: Head includes preload hints
Doc->>U: Link rel=preload Href=_framework/dotnet.js (as=script)
Doc->>U: Link rel=preload Href=_framework/blazor.boot.json (as=fetch)
U->>U: Preload dotnet.js and blazor.boot.json
U->>FW: Execute dotnet.js
FW->>U: Fetch blazor.boot.json
Note over U,FW: App continues boot sequence
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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 pull request adds preloading functionality and standardizes HTML attribute casing across multiple websites and projects. The main purpose is to improve performance by preloading critical resources while also ensuring consistent use of PascalCase attributes for Blazor components.
- Adds preload hints for critical JavaScript and JSON files across all websites
- Standardizes HTML attribute casing from lowercase to PascalCase (href → Href, src → Src)
- Configures cache control settings in service workers across projects
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Bit.Websites.Sales.Server/Components/App.razor | Adds preload links and standardizes attribute casing |
| Bit.Websites.Sales.Client/wwwroot/service-worker.published.js | Disables cache control in service worker |
| Bit.Websites.Platform.Server/Components/App.razor | Adds preload links and standardizes attribute casing |
| Bit.Websites.Platform.Client/wwwroot/service-worker.published.js | Disables cache control in service worker |
| Bit.Websites.Careers.Server/Components/App.razor | Adds preload links and standardizes attribute casing |
| Bit.Websites.Careers.Client/wwwroot/service-worker.published.js | Disables cache control in service worker |
| Boilerplate.Server.Web/Components/App.razor | Adds preload links and standardizes attribute casing |
| Boilerplate.Client.Web/wwwroot/service-worker.published.js | Adds cache control configuration with comment |
| Bit.BlazorUI.Demo.Client.Web/wwwroot/service-worker.published.js | Adds cache control configuration |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/service-worker.published.js (1)
12-16: Fix “Carrers” typos in asset URLs and manifest metadata
src/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/service-worker.published.js
• Line 12:"Bit.Websites.Carrers.Server.styles.css"→"Bit.Websites.Careers.Server.styles.css"
• Line 15:"Bit.Websites.Carrers.Client.bundle.scp.css"→"Bit.Websites.Careers.Client.bundle.scp.css"src/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/manifest.json
• Line 7:"id": "bitCarrersWebsite"→"id": "bitCareersWebsite"
• Line 11:"name": "bit Carrers"→"name": "bit Careers"
• Line 13:"short_name": "bit Carrers"→"short_name": "bit Careers"
• Line 16:"description": "bit Carrers website"→"description": "bit Careers website"Verify the corrected filenames match the actual published assets.
🧹 Nitpick comments (8)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/wwwroot/service-worker.published.js (1)
23-24: Add an explanatory inline comment for consistency.Other projects (Boilerplate) document the flag; mirror that here to avoid ambiguity.
-self.enableCacheControl = false; +self.enableCacheControl = false; // false: respect origin Cache-Control; true: SW manages cache headerssrc/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/service-worker.published.js (1)
24-24: Mirror the inline doc used in Boilerplate for clarity.-self.enableCacheControl = false; +self.enableCacheControl = false; // false: respect origin Cache-Control; true: SW manages cache headerssrc/Websites/Platform/src/Bit.Websites.Platform.Client/wwwroot/service-worker.published.js (2)
24-24: Add the same inline doc as the template for consistency.-self.enableCacheControl = false; +self.enableCacheControl = false; // false: respect origin Cache-Control; true: SW manages cache headers
23-27: Reduce config drift across SW files by centralizing shared flags.Consider generating service-worker.published.js from a shared template or small config module so flags like prerenderMode/enableCacheControl stay in sync across sites.
src/Websites/Sales/src/Bit.Websites.Sales.Client/wwwroot/service-worker.published.js (1)
24-24: Document the flag inline to match other projects.-self.enableCacheControl = false; +self.enableCacheControl = false; // false: respect origin Cache-Control; true: SW manages cache headerssrc/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor (1)
18-19: Solid preloads; consider placement and module nuance.Optionally move preloads higher in head to maximize early fetch. If your runtime loads dotnet.js as an ES module in some builds, consider testing modulepreload vs script for best effect.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Components/App.razor (2)
35-36: Preconnects: add crossorigin to google.com as well.Consistently mark cross-origin preconnects; you already did for gstatic.
Apply:
-<Link rel="preconnect" Href="https://www.google.com" /> +<Link rel="preconnect" Href="https://www.google.com" crossorigin />
63-68: Stylesheets declared in body: confirm they’re hoisted by HeadOutlet.If these Links aren’t being moved to head at render, consider relocating to head for deterministic ordering.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
📒 Files selected for processing (9)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/wwwroot/service-worker.published.js(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/service-worker.published.js(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Components/App.razor(3 hunks)src/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/service-worker.published.js(1 hunks)src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor(2 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/wwwroot/service-worker.published.js(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor(2 hunks)src/Websites/Sales/src/Bit.Websites.Sales.Client/wwwroot/service-worker.published.js(1 hunks)src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build api + blazor web
- GitHub Check: build blazor hybrid (windows)
- GitHub Check: build api + blazor web
- GitHub Check: build blazor hybrid (iOS-macOS)
- GitHub Check: build blazor hybrid (android)
- GitHub Check: build api + blazor web
- GitHub Check: build blazor hybrid (windows)
- GitHub Check: build and test
- GitHub Check: build and test
🔇 Additional comments (18)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/service-worker.published.js (1)
117-118: LGTM — clear comment and correct placement before importScripts.src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor (4)
10-10: Casing switch to Link Href is correct.Matches Blazor’s Link component parameter naming; good cleanup across icons, manifest, and styles.
Also applies to: 12-18
32-32: Script Src casing update is correct.
34-35: Script includes switched to Src look good.
20-21: Preload tags consistent; verify fetch options and add crossorigin if needed
- Confirmed no lowercase
href/srcoccurrences and allApp.razorfiles include both<Link rel="preload" Href="_framework/dotnet.js">and<Link rel="preload" Href="_framework/blazor.boot.json">.- Ensure the Blazor runtime’s fetch
mode/credentials/cachesettings match the preload so the browser reuses it (avoiding double-fetch); if any responses are served cross-origin, addcrossoriginon the preload tags.src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor (2)
9-9: Href casing updates on Link elements look good.Also applies to: 11-16
30-30: Script Src casing and ordering are fine.Also applies to: 32-34
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Components/App.razor (6)
39-39: Preconnect to app server address looks good (PWA).
41-41: Favicon Link with Href: OK.
44-44: Azure Monitor preconnect with crossorigin: OK.
54-56: Apple touch icon and manifest Href casing updates: OK.
57-58: Good preloads; confirm reuse and measure impact.Same-origin is fine; if fetched with credentials or differing cache mode, preload may not be reused—worth a quick trace in DevTools.
94-94: bit-bswup.progress.js Src casing change: OK.src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor (5)
10-10: Href casing updates on favicon/apple/manifest look good.Also applies to: 12-13
35-39: Stylesheet Links switched to Href: OK.
41-42: Preloads added: OK; verify they’re actually reused by the boot sequence.Watch for duplicate network requests to blazor.boot.json/dotnet.js due to mismatched request options.
53-53: bit-bswup.progress.js Src casing: OK.
55-56: Script Src casing updates look good.
closes #11334
Summary by CodeRabbit
New Features
Refactor
Chores