I'm having a problem with making .js files for my javascript project using visual studio2013. Where should i save made file to make it work with my project?

Dani AI

Generated

opened the thread about creating .js files in VS2013 and pointed toward using external script files. A couple of Visual Studio specifics make the difference between a working file and one that never gets served.

In VS2013 web projects, put reusable scripts in a single folder (many project templates use a Scripts folder). Add new files with Add → New Item → JavaScript File so they appear in Solution Explorer. If a file is on disk but not shown, use Show All Files and then Include In Project. In the file Properties set Build Action to Content so the file is picked up by publishing; Copy to Output Directory is usually left at Do not copy for web projects.

For ASP.NET MVC projects, place scripts in the project Scripts folder and reference them from the layout (or register them with the bundling system). Example bundle registration in BundleConfig.cs:

bundles.Add(new ScriptBundle("~/bundles/custom").Include(
    "~/Scripts/custom.js"
));

Troubleshooting checklist: confirm the file is included in the project and published; check the browser Network tab for 404s and the Console for syntax or dependency errors; verify server paths and case sensitivity (hosting on Linux can make path case matter); ensure dependent libraries are loaded before code that uses them; and if bundling/minification is in use, make sure the file is added to the bundle.

Common blockers in VS2013: file left excluded from project, wrong Build Action, wrong publish profile, or using file:// instead of a local web server. These checks resolve most "file not working" cases without changing the script code itself.

If you are using external .js files with your HTML you need to save it in the same directory as your HTML files.

You call the external js inside your HTML file like this:

<script src = "master.js"></script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.