# What  is JavaScript? (Theoretical overview)

If you are new to the **JS** world, you may have assumed that **it is a programming language**, but **it is STRICTLY NOT**. It is **simply a scripting language** that has taken over the web world.

Huh? **That's cool, right?** Let's dive deep!

JS is a **Lightweight**, **Interpreted,** and **Just-In-Time** scripting language. We don't need any external compiler to convert it into machine code and get the output (just like **JAVA**). All we need is a browser and your script file.

Js is **synchronous** (i.e., **step by step**). It can only **execute line by line.** Some cool techies even use the term "**JS is an event-driven** language" which means everything will get happen based on events (i.e., **onLoad**, **onClick**, **OnMouseOver**, etc...)

**Js** is **single-threaded**, which means it can handle **only one operation at a time**. However, we can use the **event-loop** concept to give **JS the superpower** to perform **asynchronously**.

**NOTE: Thanks to** **C++, most of the JS operations** are extensively written in this low-level language**. Don't think JS is capable to handle asynchronous activities under the hood C++ is helping us**

## How do I use the script?

All we need is an HTML file. We can add our script just above the closing section of the **&lt;body /&gt;** tag.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676635733002/8700dfdc-119d-43f2-baf2-bb017822160e.png align="center")

## Think before you add! (Loading strategy)

Adding one script file is easy, but if you have multiple scripts, loading them in the right order is much more important.

  
Sometimes there may be a situation where **script3.js** code is dependent on **script2.js** considering this (if **script3.js** loads first **before script2.js**), then our application will **crash**!

To handle the situation we can make use of **"async"** and **"defer"**

**ASYNC (default behavior):** Here, our script will get executed as soon as it gets downloaded. There will be **no control over the order** we expect.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676635477462/cf1980ac-fc46-4376-bf56-e145603ea80f.png align="center")

**DEFER:** If you want an **ordered way to execute your code,** then approach it this way.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676635235842/9c87b33a-4c22-4881-8cb9-91cc1ebe9b9f.png align="center")

## Hey Devs!

Thank you very much if you came this far. I assume this blog has provided theoretical knowledge of **JS**. Please share if you find this interesting.

Please feel free to reach me on [Twitter](https://twitter.com/socalled_dev), [LinkedIn](https://www.linkedin.com/in/ranjan-r-bb343b130/)
