[wp-trac] [WordPress Trac] #53507: Block style version: replace filemtime with version from Block API metadata
WordPress Trac
noreply at wordpress.org
Thu Jun 24 19:33:51 UTC 2021
#53507: Block style version: replace filemtime with version from Block API metadata
----------------------------+----------------------------------------
Reporter: hellofromTonya | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: 5.5
Severity: normal | Keywords: needs-patch good-first-bug
Focuses: |
----------------------------+----------------------------------------
In `register_block_style_handle` function, the version used for
registering a style handle is the file's modification time (via
`filemtime`).
This should be removed in favor of using the block's version in its
metadata.
Why?
A block is a package. In that package is everything the block needs
including its script and styles. When the block changes, the version
reflects the block's new version. Following that line of thinking, the
version registered via the [https://developer.wordpress.org/block-editor
/reference-guides/block-api/block-metadata/#wpdefinedasset Block API] is
the block's version, meaning its the version for the script and styles.
Setting the version is optional. When it's not set, then like other
assets, it defaults to `false`.
Why not `filemtime()`?
Performance. This function hits the filesystem which takes time and
memory. Using it in development is the norm and acceptable. But in
production, it's less performant than using the supplied version when
registering the block.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53507>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list