Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Sep 3, 2025

closes #11334

Summary by CodeRabbit

  • New Features

    • Added preload hints for framework assets to improve initial load times across apps.
    • Introduced a service worker option for cache-control management (disabled by default).
  • Refactor

    • Standardized Link and Script attribute casing for consistency across pages.
  • Chores

    • Applied the new cache-control flag to service workers in multiple projects.

@ysmoradi ysmoradi requested review from Copilot and msynk September 3, 2025 10:47
@coderabbitai
Copy link

coderabbitai bot commented Sep 3, 2025

Walkthrough

Introduces 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

Cohort / File(s) Summary
Service worker: enableCacheControl flag
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/wwwroot/service-worker.published.js, src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/service-worker.published.js, src/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/service-worker.published.js, src/Websites/Platform/src/Bit.Websites.Platform.Client/wwwroot/service-worker.published.js, src/Websites/Sales/src/Bit.Websites.Sales.Client/wwwroot/service-worker.published.js
Adds global self.enableCacheControl = false;. No other logic changes.
Server App.razor: attribute casing and preload
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Components/App.razor, src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor, src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor, src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor
Switches href/src to Href/Src in Link/Script. Adds preload Link entries for _framework/dotnet.js (as script) and _framework/blazor.boot.json (as fetch).

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Preload critical assets across websites (_framework/dotnet.js and blazor.boot.json) [#11334]

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Introduce global flag self.enableCacheControl = false; (src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/wwwroot/service-worker.published.js: ~top of file) Not related to asset preloading in #11334.
Introduce global flag self.enableCacheControl = false; (src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/service-worker.published.js: ~top of file) Not related to asset preloading in #11334.
Introduce global flag self.enableCacheControl = false; (src/Websites/Careers/src/Bit.Websites.Careers.Client/wwwroot/service-worker.published.js: ~top of file) Not related to asset preloading in #11334.
Introduce global flag self.enableCacheControl = false; (src/Websites/Platform/src/Bit.Websites.Platform.Client/wwwroot/service-worker.published.js: ~top of file) Not related to asset preloading in #11334.
Introduce global flag self.enableCacheControl = false; (src/Websites/Sales/src/Bit.Websites.Sales.Client/wwwroot/service-worker.published.js: ~top of file) Not related to asset preloading in #11334.

Poem

I thump my paws—preload’s in flight,
dotnet.js gleams, boot JSON alight.
Href and Src stand tall, precise,
The pages warm, the hops feel nice.
With caches calm and scripts that zoom,
This bunny ships a faster bloom. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Copilot AI left a 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

Copy link

@coderabbitai coderabbitai bot left a 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 headers
src/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 headers
src/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 headers
src/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

📥 Commits

Reviewing files that changed from the base of the PR and between eb3a953 and 809286e.

📒 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/src occurrences and all App.razor files 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/cache settings match the preload so the browser reuses it (avoiding double-fetch); if any responses are served cross-origin, add crossorigin on 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.

@ysmoradi ysmoradi merged commit 296180a into bitfoundation:develop Sep 3, 2025
28 of 30 checks passed
@ysmoradi ysmoradi deleted the 11334 branch September 3, 2025 12:12
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.

Some assets must be preload across websites

1 participant