html script tag not using type javascript [removed]?

前端 未结 2 1988
野趣味
野趣味 2021-01-01 21:18

I was checking out the source on an html page and came across this



        
2条回答
  •  遥遥无期
    2021-01-01 22:00

    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!

提交回复
热议问题