Skip to content
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

Subdomain loads require 30MiB download every time #93

Closed
lidel opened this issue Mar 7, 2024 · 3 comments · Fixed by #188
Closed

Subdomain loads require 30MiB download every time #93

lidel opened this issue Mar 7, 2024 · 3 comments · Fixed by #188
Assignees
Milestone

Comments

@lidel
Copy link
Member

lidel commented Mar 7, 2024

The ./dist without .gz files is ~30MiB.

This means every website that is loaded via subdomain gateway will re-download the same payload before SW can be initialized. This adds 30MiB cost to every website's initial load.

We should reduce the size of subdomain load to minimum to initialize worker. Ideas welcome!

Ideas

  • Perhaps we can reuse already cached verified-fetch assets from the root domain, avoid fetching them again, and only have light sw.js handling registration?
  • ?
@SgtPooki SgtPooki self-assigned this Mar 8, 2024
SgtPooki referenced this issue Mar 9, 2024
* refactor: remove unused helia andu se verified fetch

* chore: remove empty line

* fix: load config iframe using a hash fragment

fixes #88

* fix: load default config initially

* chore: fix linting errors

* chore: remove unused deps

* chore: re-add needed @helia/ipns dependency

* fix: set verifiedFetch when sw is activated

* chore: remove lib/heliaFetch and cleanup sw.ts (#95)

* fix: config loading on subdomains waits for updated config (#94)

* fix: config loading on subdomains waits for updated config

* fix: remove event.waitUtil inside channel.onmessagefrom

the activate event is fired when the service worker is first activated,
and then the channel.onmessagefrom event listener is set up.
by the time the channel receives any messages, the event passed to activate
will be done, and waitUntil has no effect (and throws an error)

* fix: service worker handles being disposed of

* fix: preload request from redirect page is handled by sw

* chore: better trace logging for config updates

---------

Co-authored-by: Daniel N <2color@users.noreply.github.com>
Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
@SgtPooki
Copy link
Member

another potential reduction in downloaded resources for subdomains: split all required assets for redirect page into a separate chunk, and update app.tsx to use dynamic imports for different pages

@SgtPooki
Copy link
Member

do we have agreed-upon action items for this? If my above proposal is appropriate, then actions should be roughly like so:

  • create src/non-subdomain.ts and src/subdomain.ts
  • add the above as entries to webpack
  • make src/app.ts dynamically load the above based on context
  • be sure that src/index.ts is the only file being loaded by webpack, and that it's lightweight (subdomains will load src/index.ts + public/index.html + src/sw.ts)

@SgtPooki
Copy link
Member

SgtPooki commented Apr 8, 2024

@lidel thoughts here? should we spend any time working on dynamic loading or are we good as is since resources should be cached from the hosted domain?

@SgtPooki SgtPooki added this to the Alpha milestone Apr 8, 2024
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 a pull request may close this issue.

2 participants