-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SPT: immediately render modal with empty thumbnails #35713
Conversation
@@ -26,6 +26,10 @@ const TemplateSelectorItem = props => { | |||
blocks = [], | |||
} = props; | |||
|
|||
if ( ! blocks.length && 'blank' !== value ) { |
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.
Rather then checking for blocks here, how do you feel about testing this.state.blocks
in PageTemplateModal.render()
?
if ( ! this.state.isOpen || isEmpty( this.state.blocks ) ) {
return null;
}
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.
I still think the component should function when the props aren't provided as expected. It makes them more resilient when moved to an alternative use case.
This doesn't preclude your change happening as well.
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
0e3e834
to
f35651c
Compare
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.
Async rendering these is a massive win. Great workl
...iting-plugin/starter-page-templates/page-template-modal/components/template-selector-item.js
Outdated
Show resolved
Hide resolved
...ll-site-editing/full-site-editing-plugin/starter-page-templates/page-template-modal/index.js
Outdated
Show resolved
Hide resolved
...-plugin/starter-page-templates/page-template-modal/styles/starter-page-templates-editor.scss
Outdated
Show resolved
Hide resolved
3bb6a5e
to
1d7b508
Compare
...ll-site-editing/full-site-editing-plugin/starter-page-templates/page-template-modal/index.js
Outdated
Show resolved
Hide resolved
5ec9a94
to
50b024c
Compare
9fd07ab
to
ae8adf1
Compare
Page load times are still extremely long. Locally it takes 9s to fully load the page, including the thumbnail previews. With static thumbnails it's 3s (which is still long). I'm afraid we'll need to do better before this is mergeable. :/ |
@youknowriad Do you happen to have any ideas how we can cut down on the time it takes to setState here? |
I've measured both process. The reduce loop wich contemplates parsing all block of all templates: |
Another thing I forgot to mention that is I'm testing this PR together with this one, reducing the delay before to start to compute the scale factor from 100ms to 0, through of the |
I assume that's the setState that sets the block list and triggers the rendering. I fear that there's not much we can do there. things to consider maybe:
|
Preview mode is something that worths to dive imo. We talked about this a few weeks ago. |
d1ac5a0
to
653f7ff
Compare
squash: add isTemplateLoadingBySlug to state enable dynamic preview. propagate template parsing state show spinner when still parsing spt: adjust thumbs spinner position
653f7ff
to
51555a0
Compare
Cleaning up older pull requests as part of a GitHub scrub. Is this change still valid? What's needed to move this along? It looks like an important performance boost. CC @retrofox If not valid, please close with a comment. Thanks! |
This PR has been marked as stale due to lack of activity within the last 30 days. |
There's a new version of SPT out now, let's close this. |
Changes proposed in this Pull Request
This PR changes slightly the approach in how the thumbnails are dynamically previewed.
Although it doesn't depend strictly on WordPress/gutenberg#17242, it will improve reduce the previewing time even for all thumbnails and as well as the large preview (100ms)
Overview
The current behavior waits to get the templates parsed before to start to render and mount the components. It produces a delay when the template modal appears. In order to improve the performance and the user perception, I purpose the following more important changes in this PR:
Disengage
the parsing process from the react component, starting to process as fast as possible without waiting for the component lifecycle.Do not update the state
with the parsed templates blocks. Update the state seems to take considerable time.Add a
templates-parser.js
which acts as a data store and global event dispatcher. It contains selectors in order to get the desired data.Dispatch onTemplateParse
global event to communicate with the component. The event dispatcher sends all data about templates in the event object argument:The event detail object contains the following fields:
blocks
: list of the parsed blockscount
: the number of blocksisEmpty
:true
is the template doesn't have content.isParsing
: defines if the template is being parsed or not.title
: template title.slug
: template slug.Testing instructions
Apply the patch and confirm that you see the spinners in the thumbnails when the templates are being parsed.
Static vs Dynamic
Tests
Parsing One By One