2

I have urls of external js and css like below. These urls are apis not related to the main application.

http://localhost/media/10/custom.js, 
http://localhost/media/11/custom1.js, 
http://localhost/media/12/custom2.js, 
http://localhost/media/13/custom3.js, 
http://localhost/media/14/custom4.js

I want to do bundle and minify these url files

Dim urls(5) as string
urls(0)=http://localhost/media/10/custom.js
urls(1)=http://localhost/media/11/custom1.js
urls(2)=http://localhost/media/12/custom2.js
urls(3)=http://localhost/media/10/custom3.js
urls(4)=http://localhost/media/10/custom4.js
BundleTable.Bundles.Add(New ScriptBundle("~/Content/js").Include(urls))
BundleTable.EnableOptimizaions=True

I am getting the below error:

the URL '....' is not valid. Only application relativenURLs (~/url) are allowed.

How can I bundle the external files?

Jasen
14.3k3 gold badges55 silver badges70 bronze badges
asked Dec 30, 2016 at 2:15
1
  • 2
    Only application relativenURLs (~/url) are allowed Commented Dec 30, 2016 at 2:26

1 Answer 1

1

There is no way to bundle external resources. And it have no sense, according to msdn Bundling and Minification

Bundling is a feature that makes it easy to combine or bundle multiple files into a single file. Because bundling combines multiple files into a single file, it reduces the number of requests to the server that is required to retrieve and display a web asset, such as a web page.

If you are bunlde external resource the bunlder has to download them (it doesn't help you to minimize requests) and check if resources are updated.

Yes, you could bundle cdn resources, If you go to Announcing the Microsoft AJAX CDN you see:

When the browser requests the script file it will be automatically served by the CDN "edge cache" server that is closest to the end-user. This means:

  1. The request will be processed much faster than if it had to hit your web-server (making the end-user's page load much faster)

  2. You don't have to pay for the bandwidth of this file – since the file comes from our server we pay the bandwidth cost (saving you money)

  3. The script can be easily cached across multiple web-sites – which means it might not even need to be downloaded if the user has already hit a web-site that requested the file (and as such has it already in the browser's cache).

Server don't download them but just redirect to them. And it makes difference.

Even it gives one more advantage, browsers has limitation of six simultaneous connections per each hostname. It can be mitigated by using a cdn. Because the cdn will have a different hostname than your hosting site.

answered Dec 30, 2016 at 2:32

3 Comments

we can bundle cdn urls. then i think we can bundle these external js urls because these urls are like cdn only. please correct me if i am wrong.
so these urls of js files what we are generating are like cdns only or different? is it possible to bundles these files. I need to do these bundling for my application so please suggest me a solution.
they aren't like cdn. Why you doesn't download them? You can't do bundling. If you need them very much you could just add them without bundling like <script src="localhost/media/10/custom.js"></script>, but there will be no optimization.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.