Mobile app version of vmapp.org
Login or Join
Dunderdale272

: Reference single javascript file from many web applications I have a javascript file (called secure.js that has several functions defined in it. I also have a Visual Studio solution with ten

@Dunderdale272

Posted in: #Cdn #Javascript

I have a javascript file (called secure.js that has several functions defined in it. I also have a Visual Studio solution with ten different ASP.NET web applications. I want to be able to call the javascript functions in secure.js from aspx pages in all of my applications.

Do I have to copy the .js file into a directory under each of the applications, and in my aspx pages reference the secure.js file that is local to that application? Is there a way to serve up the javascript file from a single location (something like jQuery being referenced from a CDN)?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Dunderdale272

1 Comments

Sorted by latest first Latest Oldest Best

 

@Pope3001725

You can call that same file from a full URL and have it used in every/many applications without it physically being present in the file structure of each application.

<script src="http://www.someotherwebsite.com/secure.js"></script>


Remember, JavaScript files, just like CSS files or images are resources that are downloaded separately from the main HTML file. They do not have to be part in the same file structure or in the same domain as the main HTML file. In fact, if you place your JavaScript files in a CDN or a subdomain or a different domain altogether you will probably speed up the performance of your application.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme