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
 
 
 

3 ways of including JavaScript in HTML的更多相关文章

  1. JavaScript Libraries In A TypeScript Application, Revisited

    If you haven’t already gotten involved with it, you’ll probably know that TypeScript is becoming inc ...

  2. Code optimization and organization in Javascript / jQuery

    This article is a combined effort of Innofied Javascript developers Puja Deora and Subhajit Ghosh) W ...

  3. springcloud starter(一)

    Spring Cloud - Getting Started Example, 转载自:https://www.logicbig.com/tutorials/spring-framework/spri ...

  4. 翻译:打造Edge渲染内核的浏览器

    最近开始了解UWP和Edge内核,在微软技术博客中找到一篇文章,主要是介绍Edge渲染内核使用技术.顺手翻译了一下.不对之处请斧正! Over the past several months, we ...

  5. 轻松解决Linux安装Eclipse方法

    随着Linux的发展,很多人开始学习Linux系统,你了解Linux系统么?你是Linux系统的应用者么?本文为你详细介绍Linux安装Eclipse,为你在学习Linux安装Eclipse时起一定的 ...

  6. 30+学习Web设计和开发的优质新鲜资源

    今天我们整理了一些最新的Web设计和开发的资源,这些资源都来自国外的流行站点,不过大家应该不会陌生,放在这里供大家收藏,在需要的时候方便翻阅和学习! 原文地址:http://www.goodfav.c ...

  7. JS外链

    <script type=”text/javascript” src=”example.js”></script>   外链的javascript都有一个.js的后缀,但是这并 ...

  8. The Chain Of Responsibility (1)

    今天分享一下,设计模式中的责任链模式,其余的不过多叙述. 思路 在正式接触责任连之前,我们可以想象到的应该是一个链,链表?要处理一件事需要一个链似得?其实答案差不多就是这样.设计模式也都是从朴素的思维 ...

  9. 20+ Docs and Guides for Front-end Developers (No. 5)

    It’s that time again to choose the tool or technology that we want to brush up on. If you feel like ...

随机推荐

  1. 本地添加Maven管理

    Maven下载安装: 1 .Maven下载地址:http://maven.apache.org/ 2 .下载解压到本地指定目录:记住该路径! 3 .新建/修改环境变量-系统变量: 名:M2_HOME ...

  2. hibernate课程 初探单表映射2-6 session详解(下)

    本节主要内容: 1 介绍了getCurrentSession和opensession的区别 2 demo:通过打印比较两个session是否相同,验证两个session是否是同一session 3 d ...

  3. Android RxJava2+Retrofit2单文件下载监听进度封装

    RxJava2和Retrofit2用的越来越多,最近也在封装一个通用的网络请求库,其中就包括了单文件下载的方法,所以这里进行记录.文末附带Demo 由于网上很多的方法都是使用拦截器进行进度的监听,个人 ...

  4. 【MATLAB】画平行于坐标轴的曲线

    hold on; ylim=get(gca,'Ylim'); % 获取当前图形的纵轴的范围 plot([4,4],ylim,'m--'); % 绘制x=4的直线 hold off;

  5. CST,CET,UTC,GMT,DST,Unix时间戳几种常见时间概述与关系(转)

    转自:http://www.cnblogs.com/frontendBY/p/5215785.html 1.UTC: Universal Time Coordinated 协调世界时,又称世界标准时间 ...

  6. Win10 耳机无声音,扬声器有声音的解决办法

    注:适用于WIN10及WIN10.ubuntu双系统耳机无声音的问题. 在WIN10的引导下,安装了Ubuntu的桌面版,作成了双系统,可是发现了一个问题:进入Win10后插耳机会没有声音,扬声器有声 ...

  7. 两数相除赋值整数变量(T-SQL)

    MSSQL: DECLARE @_pagecount INT; ; SELECT @_pagecount; 结果为1 Mysql: BEGIN DECLARE _pagecount INT; ; SE ...

  8. HDU3308 线段树区间合并

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 ,简单的线段树区间合并. 线段树的区间合并:一般是要求求最长连续区间,在PushUp()函数中实 ...

  9. Linux进程的虚拟存储器知识点

    http://blog.csdn.net/yxccc_914/article/details/52665713 用libreoffice画表真时有点蛋疼,效率很低.. 深入理解计算机系统->虚拟 ...

  10. expect脚本中,变量的写法

    一.expect脚本中,变量的不同写法 shell脚本中定义时间变量的写法:time=`date "+%Y%m%d"` ==>>直接照搬到expect中,设置的变量是不 ...