You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove stackable_add_custom_orderby_params and stackable_add_custom_orderby
Done
These 2 filters are only here because we need to add random and menu order sorting options in the Stackable Posts block. However, it's slowing down WP because every time posts are used, the filters are also applied.
I suggest removing these 2 filters and creating our own "Post getter" rest api endpoint for the Stackable Posts block. If we create our own, then there will be no need to add filters and extend the post rest api with our own filters. If this is done, this can also fix the next entry below.
Here's a screenshot of a profiler session when saving a post
Create a new page and add a tabs block with 5 tabs containing the following: pricing table with icon list of different icons. Profile the editor URL, you'll see that the code for get_excerpt_by_post_id is slow:
Done
Upon further investigation, it appears that in src/block/posts/index.php we are registering a bunch of new rest fields for posts in register_rest_fields. By registering new rest fields, ALL rest API calls for posts will now compute for these new fields (even when the editor just loads).
We need to change this behavior because the added data are only needed during the generation of the Stackable post block's content in the editor here:
Because the field is added in register_rest_fields, now whenever posts are queried, it also calls our functions. We need to change the following:
remove the added fields from register_rest_fields or only add them when generating Stackable post block content
or, the implementation of generateRenderPostItem and usePostsQuery to query a new rest API endpoint that grabs the necessary post data for displaying in the post block content.
Create a new page and add a posts block. Profile the editor URL, you'll see that the posts block code is quite slow:
Done
Change block registration method. To check, profile the Settings > General page.Do not do this for now
Done
Our blocks are registered using the function register_block_type_from_metadata it's reading the block.json files and registering it using the properties found in those files. I think this might be slow.
We can try placing all the relevant data from block.json files into a PHP object (maybe with a script that auto-compiles things if we prove this to be a good optimization strategy) then use register_block_type to register the blocks instead. This way we do not need to do any file read/writes and might bring down the execution time.
The text was updated successfully, but these errors were encountered:
Optimizations To Do:
Remove
stackable_add_custom_orderby_params
andstackable_add_custom_orderby
These 2 filters are only here because we need to add random and menu order sorting options in the Stackable Posts block. However, it's slowing down WP because every time posts are used, the filters are also applied.
I suggest removing these 2 filters and creating our own "Post getter" rest api endpoint for the Stackable Posts block. If we create our own, then there will be no need to add filters and extend the post rest api with our own filters. If this is done, this can also fix the next entry below.
Here's a screenshot of a profiler session when saving a post
Create a new page and add a tabs block with 5 tabs containing the following: pricing table with icon list of different icons. Profile the editor URL, you'll see that the code for
get_excerpt_by_post_id
is slow:Upon further investigation, it appears that in
src/block/posts/index.php
we are registering a bunch of new rest fields for posts inregister_rest_fields
. By registering new rest fields, ALL rest API calls for posts will now compute for these new fields (even when the editor just loads).We need to change this behavior because the added data are only needed during the generation of the Stackable post block's content in the editor here:
Stackable/src/block/posts/edit.js
Line 152 in ccd91e3
Because the field is added in
register_rest_fields
, now whenever posts are queried, it also calls our functions. We need to change the following:register_rest_fields
or only add them when generating Stackable post block contentgenerateRenderPostItem
andusePostsQuery
to query a new rest API endpoint that grabs the necessary post data for displaying in the post block content.Create a new page and add a posts block. Profile the editor URL, you'll see that the posts block code is quite slow:
Change block registration method. To check, profile the Settings > General page.Do not do this for nowOur blocks are registered using the function
register_block_type_from_metadata
it's reading theblock.json
files and registering it using the properties found in those files. I think this might be slow.We can try placing all the relevant data from
block.json
files into a PHP object (maybe with a script that auto-compiles things if we prove this to be a good optimization strategy) then useregister_block_type
to register the blocks instead. This way we do not need to do any file read/writes and might bring down the execution time.The text was updated successfully, but these errors were encountered: