Passing variables from server to client using RequireJS

It’s quite common to pass variables from server to client. Common uses are bootstrapping data, syncing config setting etc. Consider the following scenario: a single page app where a user logs in and refreshes the current page. You want the user to still be logged in. The most commonly used practise is to put it in a script tag: <script type="text/javascript"> var userId = 1; </script> This way you introduce a global variable userId.