How To Open JS File And Use It


JavaScript is a scripting language that runs the internet. In this article, you are going to see how to open a JS file on different devices without executing it.

A JavaScript file is saved with the .js extension and is executed by the browser and node server.

JavaScript file is also called JS file. It is a text file that contains JavaScript code.

We are going to see how to open a JS file in different devices like android, windows, chrome, and online as a text file (without running it).

how to open js file

    Table of contents

  1. How to open js files in windows
  2. How to open js file in visual studio code
  3. How to open js file in chrome
  4. How to open js file online

How to open js files in windows

When you directly try to open a JS file in windows by double-clicking the file icon, it will try to execute it and will show an error message as shown below.

opening js file in windows

To open a JS file in windows without letting it try to execute, you need to right-click on the file and select the open with option.

When you click on the open with the option, you will see a list of all the applications that can open the file. You can select notepad (can select any application) from the list and click on the open button.

how to open js file in windows

Since JS is a text-based file and notepad is a text editor, it will open the file in notepad. You can also choose applications like Wordpad, notepad++, etc.


How to open js file in visual studio code

JavaScript is a scripting language so it is preferred by developers to open and edit these files in code editors like sublime text, atom, visual studio code, etc.

When you open a JS file in these editors they will automatically highlight the code syntax to make it easy to read and understand.

Here is how the file will look in Visual Studio Code:(Look also depends on what these you are using)

how to open js file in visual studio code

How to open js file in chrome

Opening the JS file in Chrome (browser) here means to open it as a text file and not to execute it. When you link a JS file with an HTML file, it will automatically execute the JS file.

You can open these HTML liked JS files in Chrome by opening the developer tools by clicking ctrl + shift + i and then click on the Sources tab.

In this tab, you will see a left side panel with all the files that are linked to the HTML file. You can click on the JS file to open it in Chrome.

open js file in chrome console

How to open js file online

You can open JS files online in any browser by selecting the file from your device and clicking on the open button from the form below.

If you are wondering how to open the js file in android then even in android you can use the form below and it will show you the content of your js file.

Here is the content of your file:


Conclusion

We saw how to open JS files on different devices like windows. We also saw how to open JS files in different browsers like chrome.