question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Place meta charset output at top of head

See original GitHub issue

According to the HTML5 specification,

The element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document.

However, as far as I can tell, react-helmet makes no attempt to output any configured <meta charset='...'> tag as the first thing in the <head> element; in fact it appears to always be output after the <title>. If other code is also writing to the <head> (e.g. styled-components), this could push the charset specification well past that 1024 byte cutoff.

Is it possible to modify the output order of the head elements produced by react-helmet?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:11
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
ridoansalehcommented, Apr 17, 2018

Have anyone solved this issue ?

8reactions
cwelch5commented, Mar 5, 2017

@tinynumbers on the server side, you can control the ordering of groups of head information (i.e. meta tags before title tag before link tags). And the ordering of tags should stay the same order they were given as props to Helmet. On the client, you’re right, the code doesn’t try to maintain this order. We can look into fixing that. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML meta charset Attribute - W3Schools
The charset attribute specifies the character encoding for the HTML document. The HTML5 specification encourages web developers to use the UTF-8 character ......
Read more >
Function to place meta charset="UTF-8" first position in head
I need it to be at the begging of the head section. How do I get <meta charset=“UTF-8”> to be inserted in the...
Read more >
HTML meta charset Attribute - Dofactory
The charset attribute specifies what character encoding the page uses. Browsers need to know what character set to use to be able to...
Read more >
HTML | <meta> charset Attribute - GeeksforGeeks
Attribute Values: It contains the value i.e character_set which specify the character encoding for the HTML document. Values: UTF-8: It specify ...
Read more >
Set charset meta tag with JavaScript - html - Stack Overflow
and following @sebastien-lorber suggestion, will output <meta charset="UTF-8">. as first child element of head.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found