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)?

1 Answer 1


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.

  • only question, say i put it in a scripts directory under my site root (e.g. www.mysite.com/scripts/secure.js) and reference it from there.. are there any potential security concerns with doing so? Jan 26, 2012 at 22:27
  • No, there would be no security issues from this.
    – John Conde
    Jan 26, 2012 at 22:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.