From 365767a941675399eab328abbd393ea0339fba54 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Wed, 29 Nov 2023 08:29:25 +0100 Subject: [PATCH] Performance: avoid calling postcss when not needed (#56601) --- packages/block-editor/src/utils/transform-styles/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/block-editor/src/utils/transform-styles/index.js b/packages/block-editor/src/utils/transform-styles/index.js index 4da6f6ce237950..742e3a9becaef3 100644 --- a/packages/block-editor/src/utils/transform-styles/index.js +++ b/packages/block-editor/src/utils/transform-styles/index.js @@ -19,6 +19,14 @@ import rebaseUrl from 'postcss-urlrebase'; */ const transformStyles = ( styles, wrapperSelector = '' ) => { return styles.map( ( { css, ignoredSelectors = [], baseURL } ) => { + // When there is no wrapper selector or base URL, there is no need + // to transform the CSS. This is most cases because in the default + // iframed editor, no wrapping is needed, and not many styles + // provide a base URL. + if ( ! wrapperSelector && ! baseURL ) { + return css; + } + try { return postcss( [