Skip to content

Custom CSS is injected too late #4312

Closed

Description

@fregante

This line is waiting for the tab to be visible before injecting the CSS (via elementReady('body'))

https://github.com/sindresorhus/refined-github/blob/1d9dc2fd45c8ea13d898ffd70e7bc509feaa2e01/source/features/index.tsx#L131

It should probably be moved to the top of the function, without waiting for any conditions.

Activity

  1. added
    small
    on May 3, 2021
  2. fregante commented on May 3, 2021

    @fregante
    MemberAuthor

    Also I'd replace elementReady('body') with a custom awaiter like:

    while (!document.body) {
    	await Promise.race([new Promise(setTimeout), new Promise(requestAnimationFrame)])
    }

    This is because elementReady only uses requestAnimationFrame, so nothing is run until the user switches to the tab. This means that every time you switch to the tab, there's a FOUC or delay because RG will run at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedbugsmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions