CSS loaded as incorrect charset unless explicitly declared
See original GitHub issueProvide the steps to reproduce
- Run LH on https://shkspr.mobi/blog/
- When the page reloads, the
✍
emoji incorrectly renders asâœ
.
Before LH
After LH
What is the current behavior?
Why this occurs:
- My style.css contains
content: "✍";
- It is served as
Content-Type: text/css;
with no charset. - When the devtools reloads the page after Lighthouse runs, it corrupts the text - I think into Windows-1252
- If I add
@charset "UTF-8";
at the start of the CSS file, it renders correctly after Lighthouse runs.
What is the expected behavior?
The CSS spec says, if a text encoding can’t be determined, assume UTF-8.
(I am unable to change the server to serve Content-Type: text/css; charset=utf-8
)
Environment Information
- Lighthouse version: Whatever ships with Chromium 78
- Chrome version: Version 78.0.3904.108 (Official Build) snap (64-bit)
- Operating System: Ubuntu
Related issues
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:32 (4 by maintainers)
Top Results From Across the Web
css file not loading - Stack Overflow
Specifically the browser is seeing a funny character before the DOCTYPE, since the browser is assuming the wrong character encoding, ...
Read more >Terence Eden on Twitter: "Here's an interesting bug. My CSS ...
CSS loaded as incorrect charset unless explicitly declared · Issue #10060 · GoogleChrome/lighthouse. Provide the steps to reproduce Run LH on ...
Read more >Declaring character encodings in CSS - W3C
How do I declare the character encoding of a CSS style sheet?
Read more >utf-8 displayed incorrectly | Firefox Support Forum
By the way why would the default text encoding for an html file, in the absence of an explicit specification in the head,...
Read more >How to use @font-face in CSS
The @font-face rule allows custom fonts to be loaded on a webpage. Once added to a stylesheet, ... Limit the character set, if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ve passed the 1 year anniversary of this bug - and it is still a problem. Could someone please help me fix it?
https://user-images.githubusercontent.com/837136/102726447-d792dd80-4316-11eb-86ef-75c5343271da.mp4
To reproduce:
Minimum Viable Code:
HTML
CSS
I took a look at the data in
chrome://net-export/
but nothing worthwhile there. Kinda makes sense to me, given that the memory cache lives in the renderer and net-layer is way out in the browser process.