Pass vars from php to js without ajax
<p>Lets say I have a php page... I want the javascript in that page to access some user information variables (after logged in), such as userid, email, etc. If I use ajax, then it will take an extra half second, because the page has to load, then wait for ajax to go get those variables, so I'd rather embed it in the page, but that seems questionable as far as security to embed an email in the source. </p>

<p>Here are my options can you think of a better way?</p>

<p>1 - Embed the data into the php on the first request</p>

<pre><code>&lt;html&gt;
&lt;script&gt;
    user_email='&lt;?php echo $user_email; ?&gt;';
&lt;/script&gt;
</code></pre>

<p>2 - Have data load separately from a js/php file so its not in original page source</p>

<pre><code>&lt;html&gt;
&lt;script src="userdata.js.php"&gt;&lt;/script&gt;

--- userdata.js.php ---

user_email='&lt;?php echo $user_email; ?&gt;';
</code></pre>

<p>3 - Request data via ajax after page loads (would be slower)</p>

<pre><code>&lt;html&gt;
&lt;script&gt;
$(function(){
  $.post('getuserdata.php',[],function(result){
     userdata=result;
  });
});
&lt;/script&gt;
</code></pre>
