Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundle external JavaScript files using MVC 4

I have diffrent scripts online in a url:

externalurl/inte/common/js/script1.js

externalurl/inte/common/js/script2.js

externalurl/inte//common/js/script3.js

externalurl/inte//common/js/script4.js

externalurl/inte//common/js/script15.js

How can I create a javascript bundle 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));
like image 318
user1428798 Avatar asked Nov 01 '22 23:11

user1428798


1 Answers

If you use CDN jQuery you should 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"));
}
like image 168
Jeyhun Rahimov Avatar answered Nov 12 '22 11:11

Jeyhun Rahimov