I’m building a website which imports a javascript library (located inside <head>):
<script type="text/javascript" src="@routes.Assets.at("nicedit/nicEdit.js")"></script>
which means,
every page loading (no matter which page in my website), this line exists.
I wanted to know if modern browsers download the library once, and then cache it,
or every page load – the javascript is library re-downloaded.
thanks
Under normal circumstances most browsers will cache a javascript file if it is repeatedly requested from the same url; however, my definition of normal circumstances is wrapped up in how servers are usually set up. The real result depends on what cache headers the server is sending, as well as whether or not the URL changes (which is not clear from your question).
There are lots of questions on StackOverflow about caching JavaScript. This one includes something of a compendium.