html script tag not using type javascript <script type=“text/html”>?

て烟熏妆下的殇ゞ 提交于 2019-11-30 11:34:51

Script elements that have an unknown content-type are simply ignored, in this case, the browser doesn't know how to execute a text/html script.

It's a common technique used by some JavaScript templating engines.

See also:

It's a trick that I first saw in a John Resig blog post. It's used for stuff like holding a template to be expanded later. The browser won't make any attempt to execute it.

The "benefits"? Well, it's a lot neater than keeping a string in your Javascript code directly. Because you don't have multi-line strings in Javascript, it's messy to define a template like that.

edit — ha ha yes, CMS has linked the very blog post in his answer!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!