Link external JavaScript files using MVC 4

I have different scripts on the Internet at the URL:

ExternalUrl / in / general / JS / script1.js

ExternalUrl / in / general / JS / script2.js

ExternalUrl / inter // generic / JS / script3.js

ExternalUrl / inter // generic / JS / script4.js

ExternalUrl / inter // generic / JS / script15.js

How can I create a javascript package for external javascript not in my solution?

    bundles.Add(new ScriptBundle("~/bundles/inte").Include(
            "http://url/inte/common/js/script1.js",
            "http://url/inte/common/js/script2.js",
            "http://url/inte/common/js/script2.js));
+4
source share
1 answer

If you are using jQuery CDN, you must enable CDN support. bundles.UseCdn = true;

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.UseCdn = true;   //enable CDN support

    //add link to jquery on the CDN
    var jqueryCdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js";

    bundles.Add(new ScriptBundle("~/bundles/jquery",
                jqueryCdnPath).Include(
                "~/Scripts/jquery-{version}.js"));
}
+1
source

Source: https://habr.com/ru/post/1541573/


All Articles