I have minified my javascript and my css.
Now, Which is better?
<script type='text/javascript'> <? $r = file_get_contents('min.js'); if($r) echo $r; ?> </script>
OR
<script type='text/javascript' src='min.js'></script>
Same question for CSS.
If the answer is ‘sometimes because browsers fetch files simultaneously?’ Which browsers, and what are examples of the times in either scenario.
…is better, as the user’s browser can cache the file.
Adding a parameter to the
srcsuch as the file’s last modified timestamp is even better, as the user’s browser will cache the file but will always retrieve the most up to date version when the file is modified.