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

DEV: Improve built-in browser performance marks/measurements #26758

Merged
merged 2 commits into from May 2, 2024

Conversation

davidtaylorhq
Copy link
Member

  • Rename discourse-booted to 'discourse-init' (because 'booted' makes it sound like boot was finished. When in fact, it was just starting)

  • Introduce discourse-paint, which is fired after the Ember application has been painted to the screen by the browser. This happens slightly after DOMContentLoaded

  • Add a performance.measure call to link those two marks, so they're easily visible in performance traces

Also removes an ember boot-order workaround which is no longer required.

- Rename `discourse-booted` to 'discourse-init' (because 'booted' makes it sound like boot was finished. When in fact, it was just starting)

- Introduce `discourse-paint`, which is fired after the Ember application has been painted to the screen by the browser. This happens slightly after DOMContentLoaded

- Add a `performance.measure` call to link those two marks, so they're easily visible in performance traces

Also removes an ember boot-order workaround which is no longer required.
let element = document.querySelector(
`meta[name="discourse/config/environment"]`
);
const config = JSON.parse(
decodeURIComponent(element.getAttribute("content"))
);
const event = new CustomEvent("discourse-booted", { detail: config });
const event = new CustomEvent("discourse-init", { detail: config });
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure where this is used but do we need to maintain backwards compatibility here in case there are plugins or themes relying on this event?

Copy link
Member Author

Choose a reason for hiding this comment

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

We'll need to update discourse-client-performance, yeah. I'm not aware of anything else relying on it.

davidtaylorhq added a commit to discourse/discourse-client-performance that referenced this pull request May 2, 2024
- discourse-init is a direct replacement for the old discourse-booted metric.
- discourse-paint is a new metric which tells us when the Discourse UI is actually rendered to the screen

Ref discourse/discourse#26758
@davidtaylorhq davidtaylorhq merged commit 6bfc819 into main May 2, 2024
16 checks passed
@davidtaylorhq davidtaylorhq deleted the perf-marks branch May 2, 2024 22:07
davidtaylorhq added a commit to discourse/discourse-client-performance that referenced this pull request May 2, 2024
- discourse-init is a direct replacement for the old discourse-booted metric.
- discourse-paint is a new metric which tells us when the Discourse UI is actually rendered to the screen

Ref discourse/discourse#26758
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants