Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

During the reviews of #12187 we found out that the cover block contains some editor specific styles on the front end.
This is a problem because we would be transferring bytes on the frontend of websites that are not used at all.
This PR just moves this styles to editor.scss so they are loaded only in the editor.

How has this been tested?

I checked that there was no noticeable change on the cover block (and its placeholder).

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Seems legit, did you try by inverting the components and block-library enqueue order?

@jorgefilipecosta
Copy link
Member Author

Hi @youknowriad,
I tried to force both orders with:

--- a/lib/client-assets.php
+++ b/lib/client-assets.php
@@ -418,7 +418,7 @@ function gutenberg_register_scripts_and_styles() {
        gutenberg_override_style(
                'wp-editor',
                gutenberg_url( 'build/editor/style.css' ),
-               array( 'wp-components', 'wp-editor-font', 'wp-nux' ),
+               array( 'wp-editor-font', 'wp-nux' ),
                filemtime( gutenberg_dir_path() . 'build/editor/style.css' )
        );
        wp_style_add_data( 'wp-editor', 'rtl', 'replace' );
@@ -434,7 +434,7 @@ function gutenberg_register_scripts_and_styles() {
        gutenberg_override_style(
                'wp-components',
                gutenberg_url( 'build/components/style.css' ),
-               array(),
+               array( 'wp-block-library' ),
                filemtime( gutenberg_dir_path() . 'build/components/style.css' )
        );
        wp_style_add_data( 'wp-components', 'rtl', 'replace' );

and

--- a/lib/client-assets.php
+++ b/lib/client-assets.php
@@ -442,7 +442,7 @@ function gutenberg_register_scripts_and_styles() {
        gutenberg_override_style(
                'wp-block-library',
                gutenberg_url( 'build/block-library/style.css' ),
-               current_theme_supports( 'wp-block-styles' ) ? array( 'wp-block-library-theme' ) : array(),
+               current_theme_supports( 'wp-block-styles' ) ? array( 'wp-block-library-theme', 'wp-components' ) : array( 'wp-components' ),
                filemtime( gutenberg_dir_path() . 'build/block-library/style.css' )
        );
        wp_style_add_data( 'wp-block-library', 'rtl', 'replace' );

Things worked as expected in both cases.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Thanks for the tests

@jorgefilipecosta jorgefilipecosta merged commit 93f2269 into master Nov 23, 2018
@jorgefilipecosta jorgefilipecosta deleted the fix/cover-block-move-editor-specific-styles-present-in-front-end-to-the-editor branch November 23, 2018 10:30
@jorgefilipecosta jorgefilipecosta added this to the 4.6 milestone Nov 23, 2018
youknowriad pushed a commit that referenced this pull request Nov 29, 2018
… editor.scss (#12236)

During the reviews of #12187 we found out that the cover block contains some editor specific styles on the front end.
This is a problem because we would be transferring bytes on the frontend of websites that are not used at all.
This PR just moves this styles to editor.scss so they are loaded only in the editor.


## How has this been tested?
I checked that there was no noticeable change on the cover block (and its placeholder).
@mtias mtias added the [Block] Cover Affects the Cover Block - used to display content laid over a background image label Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Cover Affects the Cover Block - used to display content laid over a background image

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants