title: Reliably change page title in browser history via JavaScript
body: <p>Is it possible to change title of the page in the browser history via JavaScript after the page is loaded? Should be cross-browser (of course) and work on browsers that don't support the HTML5 History API, my primary target browser is Chrome.</p>
  
  <p>I've tried a number of approaches, but none of them seem to work reliably. Here is what I've tried last (<a href="https://github.com/browserstate/history.js/" rel="noreferrer">history.js</a>):</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Standard title&lt;/title&gt;
          &lt;script src="https://rawgit.com/browserstate/history.js/master/scripts/bundled-uncompressed/html4%2Bhtml5/native.history.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script&gt;
              window.setTimeout(function(){
                  document.title = "My custom title";
                  History.replaceState({}, "My custom title", window.location.href);
              }, 3000);
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If I load the history page in Chrom within 3 seconds after page load, I see <code>Standard title</code>, after 3 seconds I get <code>My custom title</code>.</p>
  
  <p>Why I need this: I have a JavaScript-only app (Angular 1) which runs on different environments (dev, test, production). I'd like to display a title like <code>MyApp (&lt;environmentName&gt;)</code>, but I don't want to build separate versions of my app per environment. Instead, the app could request the environment info from the backend via AJAX and update the title of the page. All of this works fine (the page title gets updated), but browser history still shows "standard" title.</p>
  
  <p>Is there a way to change title of the page in the browser history as well?</p>