-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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
});