如何正确添加CDN到Meteor 1.5项目?

时间:2017-09-30 06:57:01

标签: meteor

我在/client/main.html

中有这个
<head>
  <title>Meteor ESP8266</title>
  <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
  <script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
</head>

<body>
  <div id="app"></div>
</body>

bootstrap-toggle.min.js的CDN给了我Uncaught ReferenceError: jQuery is not defined,因为在加载Meteor的内置jQuery之前加载了CDN的javascript。

在Meteor 1.5中从CDN添加JS的正确方法是什么?

1 个答案:

答案 0 :(得分:3)

只需在defer标记中添加<script>属性:

<script defer src="..."></script>

这将导致浏览器在解析文档后执行脚本(并且已加载其他脚本)。

MDN documentation