The very simplest way to "require" or "import" to modularise javascript ASP.Net MVC 5, Visual Studio 2015
<p>All I would like to do is to be able to modularise my javascript/jquery/ajax client-side code, to use some existing library code which I have written and now want to use in the scripts section of my pages -  using something simple like in Node "require" or ES6 "import" syntax.</p>

<p>[ASP.Net MVC 5, Visual Studio 2015]</p>

<p>In webpage:</p>

<pre><code>@section scripts
{

    @Scripts.Render("~/Scripts/Views/Items/Index.js")

}
</code></pre>

<p>In Index.js:</p>

<pre><code>$(function ()
{
    var myLib = require("../Shared/my-lib");
</code></pre>

<p>OR</p>

<pre><code>$(function ()
{
   import * from "../Shared/my-lib";
</code></pre>

<p>In my-lib.js:</p>

<pre><code>export var myFunction1 = myFunction1;
export var myFunction2 = myFunction2;
</code></pre>

<p>I am an experienced .NETter but a bit of a js noob, so if I am missing anything utterly obvious, please tell me kindly! I just want to keep it DRY, you know? </p>

<p>I tried just doing it as above but it throws syntax errors about either "import" or "require", so I figure it doesn't just work out of the box. </p>

<p>I've looked up Browserify and RequireJS - but that seems like a TON of fiddly setup (yeah i am fine with npm but it is all the settings files, build files, specific way of writing the library code ... etc. etc.) - do I really have to do all that just to "include"/ import some code? </p>

<p>Should I write my library as OO javascript? Would that help?</p>

<p>At the moment I am just doing:   </p>

<pre><code> &lt;script src="@Url.Content("~/Scripts/Views/Shared/my-lib.js")" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="@Url.Content("~/Scripts/Views/Item/Index.js")" type="text/javascript"&gt;&lt;/script&gt;
</code></pre>

<p>which doesn't strike me as very elegant...</p>