You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
I've found that we cannot simply convert <link rel="stylesheet"> elements to <style> ones, which is what we currently do in our router (see this call and the fetchScriptOrStyle function).
The issue is that relative URLs present in the CSS document are relative to the CSS document, e.g.:
CSS document: /wp-content/plugins/my-plugin/assets/css/styles.css
Relative URL: ../fonts/my-font.woff
Final URL: /wp-content/plugins/my-plugin/assets/fonts/my-font.woff
However, if we simply extract the CSS code and place it inside a <style> tag, we lose the CSS document URL, so it uses the current page URL instead.
HTML document: /2023/03/my-post/
Relative URL: ../fonts/my-font.woff
Final URL: /2023/03/fonts/my-font.woff
That misses the file completely. 😅
The text was updated successfully, but these errors were encountered:
You can also compare how assets are dynamically loaded for blocks registered with the inserter integrated with Block Directory. It's a very interesting use case because it works pretty similar to the client-side navigation, and in addition to that, it installs the plugin behind the scenes:
I've found that we cannot simply convert
<link rel="stylesheet">
elements to<style>
ones, which is what we currently do in our router (see this call and thefetchScriptOrStyle
function).The issue is that relative URLs present in the CSS document are relative to the CSS document, e.g.:
CSS document:
/wp-content/plugins/my-plugin/assets/css/styles.css
Relative URL:
../fonts/my-font.woff
Final URL:
/wp-content/plugins/my-plugin/assets/fonts/my-font.woff
However, if we simply extract the CSS code and place it inside a
<style>
tag, we lose the CSS document URL, so it uses the current page URL instead.HTML document:
/2023/03/my-post/
Relative URL:
../fonts/my-font.woff
Final URL:
/2023/03/fonts/my-font.woff
That misses the file completely. 😅
The text was updated successfully, but these errors were encountered: