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

Block Directory: Ensure scripts can depend on another script handles #22703

Closed
gziolo opened this issue May 28, 2020 · 4 comments
Closed

Block Directory: Ensure scripts can depend on another script handles #22703

gziolo opened this issue May 28, 2020 · 4 comments
Assignees
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Type] Task Issues or PRs that have been broken down into an individual action to take

Comments

@gziolo
Copy link
Member

gziolo commented May 28, 2020

Description

As of today, it's possible to install blocks listed in the Block Directory using the scripts returned by the API. However, the limitation is that those scripts can depend only on script handles that are used by the block editor. The idea is that it should be also possible to use custom script handles for those scripts and there would be a way to inject them on the frontend.

Related

Related Trac ticket: Consider a solution/endpoint to lazy-load scripts and styles
Proposed REST API endpoints: #21244

@gziolo gziolo added [Type] Task Issues or PRs that have been broken down into an individual action to take [Feature] Block Directory Related to the Block Directory, a repository of block plugins labels May 28, 2020
@spacedmonkey spacedmonkey self-assigned this May 28, 2020
@spacedmonkey
Copy link
Member

Something like this could work really well

add_filter( 'script_loader_tag', function( $tag, $handle ){
   $tag = str_replace( '<script ', '<script data-handle="'.handle.'" ', $tag );
   return $tag;
});

@StevenDufresne
Copy link
Contributor

What would be an example scenario that we are prepping for?

@ryelle
Copy link
Contributor

ryelle commented Jan 15, 2021

I think this is not an issue anymore after #22721/#23407 and #24117 — assets are pulled from a separate editor page so that all dependencies and inline scripts are loaded. If I'm misunderstanding the original issue, it can be reopened.

@ryelle ryelle closed this as completed Jan 15, 2021
@gziolo
Copy link
Member Author

gziolo commented Jan 15, 2021

Sounds good. I haven't seen some of the PRs referenced. If there is more work necessary, we can always file a more targeted issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

No branches or pull requests

4 participants