We have JavaScript that writes to the document title and attempts to pad it with extra spaces...
document.title = "My Title "
But this gets translated to "My Title  "
Anyone know how to prevent this?
is an HTML entity reference that represents the character reference   (see list of entities in HTML 4) that again represents the Unicode character U+00A0. Now document.title is of the type DOMString that is similar to CDATA that’s value is not parsed. That means you cannot use HTML references for document.title as the value is not parsed as HTML.
Try Javascript’s Unicode escape sequences to denote these character like this:
document.title = "My Title\u00A0\u00A0"
You can do this
const titleElement = document.getElementsByTagName('title')[0]
titleElement.innerHTML = ' '
But as pointed out, spaces of all types are stripped.
But, if you add ᠎ (the MONGOLIAN VOWEL SEPARATOR 😁) to the end, it will not strip out the previous spaces.
titleElement.innerHTML = '᠎ '
At least in Chrome.
document.title="My Title - My Subtitle";etc.