Labs ICT
🎓 SIWES/IT Login

Where To

1 min read | JavaScript Tutorial
🎓

Doing SIWES / IT attachment?

Get a structured training programme, a supervised digital logbook, and a completion certificate with LabsICT SIWES / IT.

Explore SIWES / IT Training

Where to Put JavaScript

You can add JavaScript to your HTML in three ways. Each has its place, and knowing when to use each is part of writing clean, maintainable code.

Inline JavaScript

Write JavaScript directly inside HTML event attributes. Quick and dirty — fine for one-off demos, terrible for real projects.

Internal Script Tag

Place a <script> block inside your HTML page. Better than inline, but still couples logic to the page.

External JavaScript File

The cleanest approach — put your code in a .js file and link it. Separation of concerns, caching, and reuse.


// app.js
console.log("Hello from an external file!");

Pro tip: put your <script> tags just before </body> for better page load performance.