Skip to content

Make Refined GitHub act sooner with element-ready #2604

Closed

Description

@fregante

The browser may display content on screen long before dom-ready, so sometimes content appears for a few seconds before Refined GitHub changes it. This is a bit annoying.

https://github.com/sindresorhus/element-ready can avoid this by acting on elements as soon as they appear in the DOM while the page is still loading/streaming.

GitHub sometimes loads new pages via ajax so we have to listen to both the real dom-ready event and the ajaxed one. We handle this with features.onAjaxedPages

We use element-ready in some features but there's currently no loading mechanism that combines element-ready and ajaxed loads.

Possible solutions

Here's some implementations I thought of.

A new single loading method

feature.init({
	...,
	load: features.onAjaxedPagesOrWait('selector')
});

Better yet, have a onAjaxedPages version that doesn't wait for dom-ready on the first run and element-ready can be used in the feature itself.

✅ Preferred

feature.init({
	...,
	load: features.onAjaxedPagesOrInstant
});

A completely new loading API

This would split each event and allow us to combine them in any way, but it's a bit verbose

feature.init({
	...,
	loadOnAjaxed: true,
	loadAfterElement: 'selector'
});

this means regular features (dom-ready + ajaxed) would have to be declared explicitly:

feature.init({
	...,
	loadOnDomReady: true,
	loadOnAjaxed: true
});

... other suggestions welcome

Activity

  1. added
    meta
    Please! ♥︎
    and removed
    Please! ♥︎
    on Dec 7, 2019
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

    metaunder discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions