3 ways of including JavaScript in HTML
2020-02-02 16:44
696 查看
Code written in JavaScript must be executed from a document written in HTML.
There are three ways of doing this :
1. you can place the JavaScript between <script> tags within the <head> of the document :
2. a much better technique is to place your JavaScript code into a separate file.
3. the best way is to place the <script> tag at the end of the document right before the closing
</body> tag :
Placing the <script> tag at the end of the document lets the browser load the page faster.
Programming languages are either interpreted or compiled. Languages like Java or C++ require a
compiler. A compiler is a program that translates the source code written in a high-level language like Java into a file that can be executed directly by a computer.
Interpreted languages dont require a complier -- they just need an interpreter instead.
With JavaScript, in the context of the World Wide Web, the web browser does the interpreting.
Without the interpreter, the JavaScript code would never be executed.
If there are any errors in the code written in a compiled language, those errors will pop up when the code is compiled. In the case of an interpreted language, errors won’t become apparent until the interpreter executes the code转载于:https://www.cnblogs.com/beyond-Acm/p/4794169.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 3 ways of including JavaScript in HTML
- JavaScript in HTML(Chapter 2 of Professional JavaScript® for Web Developers 2nd Edition)
- JavaScript in HTML(Chapter 2 of Professional JavaScript® for Web Developers 2nd Edition)
- javascript in html
- 4 Ways of Executing a Shell Script in UNIX / Linux
- Different ways of associating known types in wcf
- [译]the cost of javascript in 2018(1)
- JavaScript中forEach、for-in、for-of循环的比较
- What is the difference between the ways to implement inheritance in javascript.
- HR--Copy of fetching HR data in different ways
- [html] Javascript warning and error of w3c
- JavaScript之for循环的for...in和for...of
- How to get HTML code of a WebElement in Selenium
- Ch2 Javascript In HTML
- [Javascript] Proper use of console.assert in JavaScript
- how to display Error message including Html tag in apex trigger
- JavaScript里的循环方法:forEach,for-in,for-of
- JavaScript里的循环方法:forEach,for-in,for-of
- JavaScript 的 4 种数组遍历方法: for VS forEach() VS for/in VS for/of
- 讨论: TDD in HTML & JavaScript 之可行性和最佳实践