Jade: How to include a javascript file

☆樱花仙子☆ 提交于 2019-11-30 06:02:37

Put this in your jade file:

script(src="/Scripts/jquery.timeago.js")

You can put this code in your jade file:

   script(type='text/javascript' src='public/vendor/jquery/jquery.min.js')
Lawrence Chang

Also, if you would like to include inline js within your jade file you could do the following as well:

script(type="text/javascript").
console.log('hello world');
C Williams

Syntax for Adding scripts to your jade files is

script(src="",...,otherAttribute="")

example like the one below, that adds Jquery Bootstraps to the page.

  script( src="https://code.jquery.com/jquery-3.2.1.slim.min.js",  integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" ,crossorigin="anonymous")

script(src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js", integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q", crossorigin="anonymous")

  script( src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" ,integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl", crossorigin="anonymous") 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!