Skip to content

Improve feature loading mechanism - #2987

Merged
fregante merged 22 commits into
masterfrom
new-loader
Apr 14, 2020
Merged

fregante merged 22 commits into
masterfrom
new-loader

Conversation

@fregante

@fregante fregante commented Apr 9, 2020 •

Copy link
Copy Markdown
Member

New attempt at solving this: #2925 (comment)

WIP: I'll have to review this code again and do a couple of new TODOs

Why

  • Lets you add any number of listeners for AJAXed widget, like onNewComments, onNewsfeedLoad, etc.
  • The listeners themselves can be simplified to avoid having to manage onAjaxedPages internally.
  • Easier to understand (what did onAjaxedPages mean anyway?)

Changes

  • By default, run on DOM ready and AJAX pages.

  • You can customize this behavior with 3 separate options:

    • waitForDomReady: true: "fast features" will have to set this to false.
    • repeatOnAjax: true: It's the most common configuration anyway. It only has to be set to false in rare occasions.
    • repeatOnAjaxEvenOnBackButton: false: this the equivalent of the old onAjaxedPagesRaw. Only used by 3 features.
  • Pass additional listeners via additionalListeners: [] property. These listeners will be run after each page load, whether this is "document start", DOM ready or AJAX.

@fregante fregante added the meta Related to Refined GitHub itself label Apr 9, 2020
@fregante fregante changed the title New loader Improve feature loading mechanism Apr 9, 2020
@fregante

fregante commented Apr 10, 2020 •

Copy link
Copy Markdown
Member Author

@sindresorhus @yakov116 it'd be great if you could use this for a few days. It looks like it's working for me, but I haven't specifically tested the features that were "updated" the most.

`deinit` functions used to be called on every single pageload.

Now they're called only once after the feature ran.
@yakov116

Copy link
Copy Markdown
Member

@fregante I have very limited access to a computer over the next week but I will try it and let you know how it goes.

@yakov116

Copy link
Copy Markdown
Member

I haven't specifically tested the features that were "updated" the most.

@fregante what things specifically should i test?

@fregante

Copy link
Copy Markdown
Member Author

what things specifically should i test?

Any feature that was updated beyond just the drop of the load property.

Example of a feature to test:

test

Example of a feature to skip:

skip

@fregante
fregante marked this pull request as ready for review April 14, 2020 22:16
@fregante
fregante merged commit bf2a893 into master Apr 14, 2020
@fregante
fregante deleted the new-loader branch April 14, 2020 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants