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

Lazy load olvy's whats new content #7843

Merged
merged 4 commits into from
Jun 3, 2024
Merged

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented May 29, 2024

This PR configures the olvy script in such a way that it does not load the whole modal iframe on page load. Instead, the modal is lazily initialized upon the user clicking the whats new button.

A important side comment:

The large images are loaded by an iframe created by olvy. The iframe itself seems to have its own limitation of max parallel requests (per domain) (for this claim I found no clear resource but it seemed that way). Thus, I would deduce that the loading of the images was only limiting the amount of inbound data but not the amount of running parallel requests.
=> The performance increase might not be that much.

URL of deployed dev instance (used for testing):

How it works:

The init call to olvy

window.Olvy.init(OlvyConfig);

eagerly initializes the "Whats new" modal as an iframe. This loads all those large gif and other files. To make olvy load it only when needed, the config.target needs to be set to "" as the initt function check for exactly that case. Here is the snippet from the olvy script in its init function responsible for the eager loading (this pr now skips that).

 this.config.view = viewConfig;
      if (this.config.target !== "") { // <---- here 
        if (document.readyState === "complete") {
          this.__handleWidgetSetup();
        } else {
          window.addEventListener("load", () => {
            this.__handleWidgetSetup();
          });
        }
      }

The config.target is then set when the user clicks to open the "What's new" modal.

Steps to test:

  • In case you want to check whether the "how many new updates" number bubble in the top right corner of the button still works, => That is rather difficult 🙈

    • The problem arises as the default time since the last update was viewed is when the user was created -> Either test locally & edit the db entry or make a quick change to
      new Date(lastViewedTimestampWithFallback).toISOString(),
      to something like new Date("1.1.2020").toISOString(),.
    • Testing in dev instance: should be possible via db entry manipulation (but likely too much of a hassle)
  • To test the lazy loading:

    • Open a new tab, open the network tab & open the deployed dev instance in that tab.
    • None of the large images should be loaded.
    • Click the "What's new" button -> The modal should open up and now finally the large images should be fetched.

Issues:


(Please delete unneeded items, merge only when none are left open)

@MichaelBuessemeyer MichaelBuessemeyer self-assigned this May 29, 2024
Copy link
Member

@fm3 fm3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me 🎉

@MichaelBuessemeyer MichaelBuessemeyer merged commit b9999b7 into master Jun 3, 2024
2 checks passed
@MichaelBuessemeyer MichaelBuessemeyer deleted the lazy-load-olvy branch June 3, 2024 12:12
@philippotto
Copy link
Member

Here is the snippet from the olvy script in its init function responsible for the eager loading

awesome that you found this behavior and solution 🎉

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.

Lazy-load contents of "What's New" interface
3 participants