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

Experiment: Measure performance impact of loading blocks and patterns #33804

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async function runPerformanceTests( branches, options ) {
// 4- Running the tests.
log( '\n>> Running the tests' );

const testSuites = [ 'post-editor', 'site-editor' ];
const testSuites = [ 'post-editor' ];

/** @type {Record<string,Record<string, WPPerformanceResults>>} */
const results = {};
Expand Down
4 changes: 2 additions & 2 deletions lib/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function() {
return;
}
remove_core_patterns();
register_gutenberg_patterns();
// register_gutenberg_patterns();
}
);

Expand All @@ -257,7 +257,7 @@ function( $current_screen ) {

$is_site_editor = ( function_exists( 'gutenberg_is_edit_site_page' ) && gutenberg_is_edit_site_page( $current_screen->id ) );
if ( $current_screen->is_block_editor || $is_site_editor ) {
load_remote_patterns();
// load_remote_patterns();
}
}
);
20 changes: 16 additions & 4 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,20 @@ function gutenberg_reregister_core_block_types() {
$registry->unregister( $metadata['name'] );
}

gutenberg_register_core_block_assets( $folder_name );
register_block_type_from_metadata( $block_json_file );
if ( in_array( $metadata['name'], array(
'core/paragraph',
'core/image',
'core/heading',
'core/gallery',
'core/list',
'core/quote',
'core/group',
'core/freeform',
'core/missing',
) ) ) {
gutenberg_register_core_block_assets( $folder_name );
register_block_type_from_metadata( $block_json_file );
}
}

foreach ( $block_names as $file => $sub_block_names ) {
Expand All @@ -147,10 +159,10 @@ function gutenberg_reregister_core_block_types() {
if ( $registry->is_registered( $block_name ) ) {
$registry->unregister( $block_name );
}
gutenberg_register_core_block_assets( $block_name );
// gutenberg_register_core_block_assets( $block_name );
}

require_once $blocks_dir . $file;
// require_once $blocks_dir . $file;
}
}
}
Expand Down
163 changes: 1 addition & 162 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,79 +17,10 @@ import * as image from './image';
import * as heading from './heading';
import * as quote from './quote';
import * as gallery from './gallery';
import * as archives from './archives';
import * as audio from './audio';
import * as buttons from './buttons';
import * as button from './button';
import * as calendar from './calendar';
import * as categories from './categories';
import * as code from './code';
import * as columns from './columns';
import * as column from './column';
import * as cover from './cover';
import * as embed from './embed';
import * as file from './file';
import * as html from './html';
import * as mediaText from './media-text';
import * as navigation from './navigation';
import * as navigationLink from './navigation-link';
import * as homeLink from './home-link';
import * as latestComments from './latest-comments';
import * as latestPosts from './latest-posts';
import * as logInOut from './loginout';
import * as list from './list';
import * as missing from './missing';
import * as more from './more';
import * as nextpage from './nextpage';
import * as pageList from './page-list';
import * as preformatted from './preformatted';
import * as pullquote from './pullquote';
import * as reusableBlock from './block';
import * as rss from './rss';
import * as search from './search';
import * as group from './group';
import * as separator from './separator';
import * as shortcode from './shortcode';
import * as spacer from './spacer';
import * as table from './table';
// import * as tableOfContents from './table-of-contents';
import * as textColumns from './text-columns';
import * as verse from './verse';
import * as video from './video';
import * as tagCloud from './tag-cloud';
import * as classic from './freeform';
import * as socialLinks from './social-links';
import * as socialLink from './social-link';

// Full Site Editing Blocks
import * as siteLogo from './site-logo';
import * as siteTagline from './site-tagline';
import * as siteTitle from './site-title';
import * as templatePart from './template-part';
import * as query from './query';
import * as postTemplate from './post-template';
import * as queryTitle from './query-title';
import * as queryPagination from './query-pagination';
import * as queryPaginationNext from './query-pagination-next';
import * as queryPaginationNumbers from './query-pagination-numbers';
import * as queryPaginationPrevious from './query-pagination-previous';
import * as postNavigationLink from './post-navigation-link';
import * as postTitle from './post-title';
import * as postContent from './post-content';
import * as postAuthor from './post-author';
import * as postComment from './post-comment';
import * as postCommentAuthor from './post-comment-author';
import * as postCommentContent from './post-comment-content';
import * as postCommentDate from './post-comment-date';
import * as postComments from './post-comments';
import * as postCommentsCount from './post-comments-count';
import * as postCommentsForm from './post-comments-form';
import * as postCommentsLink from './post-comments-link';
import * as postDate from './post-date';
import * as postExcerpt from './post-excerpt';
import * as postFeaturedImage from './post-featured-image';
import * as postTerms from './post-terms';
import * as termDescription from './term-description';

/**
* Function to register an individual block.
Expand Down Expand Up @@ -126,66 +57,9 @@ export const __experimentalGetCoreBlocks = () => [
quote,

// Register all remaining core blocks.
shortcode,
archives,
audio,
button,
buttons,
calendar,
categories,
code,
columns,
column,
cover,
embed,
file,
group,
window.wp && window.wp.oldEditor ? classic : null, // Only add the classic block in WP Context
html,
mediaText,
latestComments,
latestPosts,
missing,
more,
nextpage,
pageList,
preformatted,
pullquote,
rss,
search,
separator,
reusableBlock,
socialLinks,
socialLink,
spacer,
table,
// tableOfContents,
tagCloud,
textColumns,
verse,
video,

// Theme blocks
siteLogo,
siteTagline,
siteTitle,

query,
postTemplate,
queryTitle,
queryPagination,
queryPaginationNext,
queryPaginationNumbers,
queryPaginationPrevious,

postTitle,
postContent,
postDate,
postExcerpt,
postFeaturedImage,
postTerms,

logInOut,
];

/**
Expand Down Expand Up @@ -215,40 +89,5 @@ export const registerCoreBlocks = (

/**
* Function to register experimental core blocks depending on editor settings.
*
* @param {boolean} enableFSEBlocks Whether to enable the full site editing blocks.
* @example
* ```js
* import { __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
*
* __experimentalRegisterExperimentalCoreBlocks( settings );
* ```
*/
export const __experimentalRegisterExperimentalCoreBlocks =
process.env.GUTENBERG_PHASE === 2
? ( { enableFSEBlocks } = {} ) => {
[
navigation,
navigationLink,
homeLink,

// Register Full Site Editing Blocks.
...( enableFSEBlocks
? [
templatePart,
postAuthor,
postComment,
postCommentAuthor,
postCommentContent,
postCommentDate,
postComments,
postCommentsCount,
postCommentsForm,
postCommentsLink,
postNavigationLink,
termDescription,
]
: [] ),
].forEach( registerBlock );
}
: undefined;
export const __experimentalRegisterExperimentalCoreBlocks = () => {};
11 changes: 11 additions & 0 deletions packages/e2e-tests/assets/small-post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- wp:heading {"level":1} -->
<h1>At iam decimum annum in spelunca iacet.</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <a href="http://example.com/" target="_blank" rel="noreferrer noopener">Sit enim idem caecus, debilis.</a> Potius inflammat, ut coercendi magis quam dedocendi esse videantur. Quis non odit sordidos, vanos, leves, futtiles? Age sane, inquam. Duo Reges: constructio interrete. Nam ante Aristippus, et ille melius. Sed quamvis comis in amicis tuendis fuerit, tamen, si haec vera sunt-nihil enim affirmo-, non satis acutus fuit. </p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>At habetur! Et ego id scilicet nesciebam! Sed ut sit, etiamne post mortem coletur?</li><li>Totum genus hoc Zeno et qui ab eo sunt aut non potuerunt aut noluerunt, certe reliquerunt.</li><li>At quicum ioca seria, ut dicitur, quicum arcana, quicum occulta omnia?</li></ul>
<!-- /wp:list -->
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/performance/post-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe( 'Post Editor Performance', () => {
};

const html = readFile(
join( __dirname, '../../assets/large-post.html' )
join( __dirname, '../../assets/small-post.html' )
);

await createNewPost();
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/performance/site-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { readFile, deleteFile, getTypingEventDurations } from './utils';

jest.setTimeout( 1000000 );

describe( 'Site Editor Performance', () => {
describe.skip( 'Site Editor Performance', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await trashAllPosts( 'wp_template' );
Expand Down