Could I encounter any problems if I included a JavaScript or CSS file in one html page more than once? For example:
<html>
<head>
...
<script src="/Scripts/MyScript.js" type="text/javascript"></script>
<script type="text/javascript" src="/Scripts/jquery.js"></script>
<script src="/Scripts/MyScript.js" type="text/javascript"></script>
...</head>
<body>
...
</body></html>
In case anybody wonders why I would want to do something like that: It’s more curiosity and I know some projects where it actually occurs.
I already checked with Fiddler and the files seem to be requested only once.
For CSS, it won’t have any effect other than to slow down the page rendering by a tiny fraction.
For JavaScript, the code will be executed twice. If the code has side-effects, those effects will apply twice. If all the JavaScript does is (eg.) define some functions, it won’t have any appreciable effect.
Under normal circumstances the files will be cached after the first read, so they won’t be fetched over the network multiple times.