-
Notifications
You must be signed in to change notification settings - Fork 117
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
Client-side JS performance optimizations #9272
Conversation
Introduced in: f157ea3 Due to an inverted condition, if the user is logged out, we would update the user's timezone context and cookie even if it wasn't changed.
<ExpandableSection> was rendering its (conceptual) children via a referentially-unstable wrapper component, so any rerenders propagating from above would cause a rerender-from-scratch with loss of state. One of the places this is used is QuickTakesSection, which contains a CkEditor comment editor. What this meant in practice is that on load, CkEditor would initialize twice on the client, duplicating a bunch of plugin-initialization work.
The way wrapCkEditor was written, you have to import (and trigger some plugin initialization for) every version of the editor (comment, post, and collaborative), regardless of which you're going to use. Make it so that you only set up the config for the one you're going to use, and memoize the config initialization.
This prevents downstream rerenders on pageload, saving some JS execution time.
import { Components, registerComponent } from "../../lib/vulcan-lib"; | ||
import PropTypes from 'prop-types'; | ||
|
||
const styles = (theme: ThemeType): JssStyles => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid returning JssStyles
, so that classes
can be typed classes: ClassesType<typeof styles>
(even though there aren't any styles in this case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this file wasn't supposed to be in this commit at all (it was hanging out in my working directory from an unrelated thing)
…to client-js-optimizations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@Will-Howard I think you forgot to make your review an approving one)
…to client-js-optimizations
Introduced in: f157ea3
Due to an inverted condition, if the user is logged out, we would update
the user's timezone context and cookie even if it wasn't changed.
was rendering its (conceptual) children via a
referentially-unstable wrapper component, so any rerenders propagating
from above would cause a rerender-from-scratch with loss of state. One
of the places this is used is QuickTakesSection, which contains a
CkEditor comment editor. What this meant in practice is that on load,
CkEditor would initialize twice on the client, duplicating a bunch of
plugin-initialization work.
The way wrapCkEditor was written, you have to import (and trigger some
plugin initialization for) every version of the editor (comment, post,
and collaborative), regardless of which you're going to use.
Make it so that you only set up the config for the one you're going to
use, and memoize the config initialization.
This prevents downstream rerenders on pageload, saving some JS execution
time.
┆Issue is synchronized with this Asana task by Unito