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

Defer React script until DOM is ready #2989

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Conversation

infinite-persistence
Copy link
Collaborator

@infinite-persistence infinite-persistence commented Oct 9, 2023

Issue

LBRY-DESKTOP-WEB-PRD Target container is not a DOM element aka "white screen"
Reproduce: make a bookmark of the site, and keep clicking it with variations in delay

Root/Change

  • React looks for a div with a specific ID, so the div must exist first.
  • There are various suggestions, from putting the script tag at the bottom-most of <body>, to listening to DOMContentLoaded.
  • The easiest seems to be the defer tag -- it's the same as async (start fetch in parallel), but only executes after the DOM is ready.

Caveat

On Chrome, clicking on a bookmark will utilize the cached version of index.html (maybe this was what some users were doing when they say they are "reloading").

The fix will only take effect on regular F5 (or clicking the button, or clicking our Reload nag).

## Issue
[LBRY-DESKTOP-WEB-PRD Target container is not a DOM element](https://sentry.lbry.tech/organizations/odysee/issues/28517/)

## Reproduce
Make a bookmark of the site, and keep clicking it with variations in delay

## Root
React looks for a div with a specific ID, so the div must exist first.

## Change
There are various suggestions, from putting the script tag at the bottom-most of <body>, to listening to `DOMContentLoaded`.

The easiest seems to be the `defer` tag -- it's the same as `async` (start fetch in parallel), but only execute it after the DOM is ready.

## Caveat
On Chrome, clicking on a bookmark will utilize the cached version of `index.html` (maybe this is what some users are doing when they say they are "reloading").

The fix will only take effect on F5 (or clicking the button, or clicking our Reload nag).
@infinite-persistence infinite-persistence merged commit 849d1db into master Oct 9, 2023
2 checks passed
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.

1 participant