You can add JavaScript code in an HTML document by employing the dedicated HTML tag <script> that wraps around JavaScript code . The <script> tag can be placed in the <head> section of your HTML or in the <body> section, depending on when you want the JavaScript to load.