Skip to content

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

Closed

Description

@gziolo

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

Activity

  1. added
    [Type] Task
    [Feature] Block Directory
    on May 28, 2020
  2. self-assigned this
    on May 28, 2020
  3. spacedmonkey commented on May 28, 2020

    @spacedmonkey
    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;
    });
    
  4. StevenDufresne commented on May 29, 2020

    @StevenDufresne
    Contributor

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

  5. ryelle commented on Jan 15, 2021

    @ryelle
    Contributor

    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.

  6. gziolo commented on Jan 15, 2021

    @gziolo
    MemberAuthor

    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

Metadata

Metadata

Assignees

Labels

[Feature] Block Directory[Type] Task

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions