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?
There is no way to bundle external resources. And it have no sense, according to msdn Bundling and Minification
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:
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.