title: Best practice: get URL parameter into JavaScript
body: <p>I have a web application and want to be able to pass an object ID via the URL:</p>
  
  <pre><code>www.example.com/?id=someObjectID
  </code></pre>
  
  <p>I then want to retrieve the Object data from the server (e.g. with an Ajax call).</p>
  
  <p>What is best practice to handle this?</p>
  
  <p>I came up with:</p>
  
  <ol>
  <li><p>analyse the URL with JavaScript.</p>
  
  <p>pros:</p>
  
  <ul>
  <li>everything is pure client side JS</li>
  </ul>
  
  <p>cons:</p>
  
  <ul>
  <li>there is no standard way for URL parameter handling in JS</li>
  </ul></li>
  <li><p>get the URL parameters server side and render them into the HTML response (e.g. inside a variable). Then make the ajax request client side.</p>
  
  <p>pros:</p>
  
  <ul>
  <li>easy URL parameter handling server side (e.g. with express)</li>
  </ul>
  
  <p>cons:</p>
  
  <ul>
  <li>parameter information makes a round trip to the server</li>
  <li>server side rendering of the website (I could start render everything server side)</li>
  </ul></li>
  </ol>
  
  <p>Are there any other options?</p>
  
  <p>What are best practice here?</p>
  
  <p>Is there any standard libraries/tools?</p>