[wp-trac] [WordPress Trac] #63695: viewStyle is loaded in the footer when the active theme is the classic theme
WordPress Trac
noreply at wordpress.org
Sat Jul 12 02:58:55 UTC 2025
#63695: viewStyle is loaded in the footer when the active theme is the classic
theme
--------------------------+-----------------------------
Reporter: wildworks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Related to #59673
Originally reported at
[https://github.com/WordPress/gutenberg/issues/70673#issuecomment-3062987346
GB 70673]
The block.json has two fields that define the styles that will be enqueued
on the frontend.
- `style`: enqueue in both the front-end and the editor
- `viewStyle` enqueued only in the front-end
How these styles are loaded depends on the active theme and whether the
page has the block.
Of the four patterns below, the behavior in the classic theme is not what
I expect. My understanding is that in the classic theme, by default, both
styles should be loaded in the head tag, regardless of whether or not
there are blocks on the page.
=== ✅ The block theme is active, and there are blocks on the page
Both styles are loaded in the head tag.
{{{
#!xml
<!DOCTYPE html>
<html lang="en-US">
<head>
<style id='create-block-test-style-inline-css'>
.wp-block-create-block-test{background-color:red}
</style>
<style id='create-block-test-view-style-inline-css'>
.wp-block-create-block-test{background-color:blue}
</style>
</head>
<body></body>
</html>
}}}
=== ✅ The block theme is active, and there are no blocks on the page
Both styles are not loaded.
=== ❌ The classic theme is active, and there are blocks on the page
- The `style` is loaded in the head tag
- The `viewStyle` is loaded outside the head tag
{{{
#!xml
<!DOCTYPE html>
<html lang="en-US" >
<head>
<style id='create-block-test-style-inline-css'>
.wp-block-create-block-test{background-color:red}
</style>
</head>
<body>
<style id='create-block-test-view-style-inline-css'>
.wp-block-create-block-test{background-color:blue}
</style>
</body>
</html>
}}}
=== ❌ The classic theme is active, and there are no blocks on the page
- The `style` is loaded in the head tag
- The `viewStyle` is not loaded
{{{
#!xml
<!DOCTYPE html>
<html lang="en-US" >
<head>
<style id='create-block-test-style-inline-css'>
.wp-block-create-block-test{background-color:red}
</style>
</head>
<body></body>
</html>
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63695>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list