【前端】text/javascript与application/javascript的区别

场景

在阅读HTMLScriptElement接口的时候,发现里面的例子在生成script标签的时候用到了 type=‘text/javascript’,而script还有一个属性值是 type=‘application/javascript’

为什么

在html5之前,推荐使用type=‘text/javascript’。在html5之后,type是可选的类型,默认还是type=‘text/javascript’,所以使用text/javascript是为了让这部分脚本代码拥有更高的兼容性。

参考资料

https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLScriptElement
https://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#h-18.2.2.2
https://www.w3.org/TR/2018/SPSD-html5-20180327/scripting-1.html#attr-script-type

With this digital Early Release edition of Programming JavaScript Applications, you get the entire book bundle in its earliest form—the author's raw and unedited content—so you can take advantage of this content long before the book's official release. You'll also receive updates when significant changes are made, as well as the final ebook version., Take your existing JavaScript skills to the next level and learn how to build complete web scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this book, you’ll learn how to write flexible and resilient code that’s easier—not harder—to work with as your code base grows., JavaScript has become one of the most widely used—and essential—programming languages for the Web, on both the client-side and server-side. In the real world, JavaScript applications are fragile, and when you change them things often break. Author Eric Elliott shows you how to add features without creating bugs or negatively impacting the rest of your code during the course of building a large JavaScript application., Early Release content now available:, AMD, Asynchronous Operations, Callbacks, Promises and Deferreds, Code Quality, Function Polymorphism, Function Scope, Hoisting and Closures, Functional Programming and Stateless Functions, Immediately Invoked Function Expressions, Interfaces, JavaScript Style Guide, Lambdas, Method Chaining and Fluent APIs, Method Context, Named Parameters, Node Modules, Object Factories, Partial Application and Currying, Plugins, Principles of Modularity, Prototypal Inheritance, Prototype Cloning and the Flyweight Pattern, The Module Pattern, Unit Testing, Coming soon:, Architecting for Scale, Collaboration, Build, Continuous Integration, Deployment, Communicating with Servers and APIs, Designing and Programming RESTful APIs with Node.js, Event-driven, Modular Client Side Application Architecture, Feature Toggles, Internationalization, Logging and Cross Cutting Concerns, Separatian of Concerns (MVC, etc.)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZeroJsus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值