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

Only load BCTT assets where they are needed [Performance] #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sabrina-zeidan
Copy link

Moving styles and scripts enqueue to the register_block callback function allows to enqueue assets conditionally -- they will be loaded on the pages where the block is used, and won't be loaded where the block is not. Should be working the same with any theme, whether it's FSE/uses Gutenberg/Classic editor etc.

Moving styles and scripts enqueue to the register_block callback function allows to enqueue assets conditionally -- they will be loaded on the pages where the block is used, and won't be loaded where the block is not. Should be working the same with any theme, whether it's FSE/uses Gutenberg/Classic editor etc.
@@ -87,6 +87,6 @@ function bctt_block_callback( $attributes ) {
'nofollow' => $nofollow ? 'yes' : 'no',
'prompt' => $prompt
), $attributes );

bctt_scripts();
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break shortcodes!, the ideal place to move this would be to shortcode here

function bctt_shortcode( $atts ) {

Copy link
Contributor

@ajitbohra ajitbohra left a comment

Choose a reason for hiding this comment

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

This will break shortcodes moving this to shortcode registration will make block and shortcode both work with the new change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants