Meteor: Injecting via "meteor add" vs using "<script>" tag

119 views Asked by At

I was trying to inject Datatables library into my meteor app, but I found that meteor doesn't always include the file injected via the <script> tag:

<script src="http://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js">

However, when I add the same file via an atmosphere package, it somehow does the job:

meteor add ksrv:datatables

Look at the source code for this package on github. It has just one file, which is exactly the same file I was trying to include earlier, but via <script> tag, and somehow, that works.

What is the difference between injecting files via <script> tags in the HTML file, and injecting files via atmosphere meteor packages?

1

There are 1 answers

0
Michel Floyd On BEST ANSWER

In Meteor development there are no patterns for using a <script> tag in html. Javascript functionality is added via:

  1. Meteor packages: meteor add packagename
  2. npm packages: npm install packagename
  3. Your own js code.

The meteor build system deals with adding all the above into your application. In a development environment you will see every script loaded individually into your HTML. In a production deployment all the javascript, both packages and your own code, is minified and concatenated into a single script that is loaded into your single page application.