3 ways of including JavaScript in HTML

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值