0

I added the underscore using npm install underscore but I am stuck on how to use it on front end .On backend var _ = require('underscore') may work and something like import {x} from underscore.js may work on front end which is ofcourse not able to work on my case.

I would like to know what is the best way of adding packages on front end (ex: I want to use bootstrap on all html files but not through using <script src="bootstrap.js"> which makes hazard as add multiple script files "

Sai Ram
  • 4,196
  • 4
  • 26
  • 39

1 Answers1

0

Just add script tag and src of underscore from npm modules so you should be able to use in your app.

<script src="node_modules/underscore"></script>

if you don't want to use script tag then you need a JS package manager like JSPM or SystemJS or webpack to load in your app

If you are using any framework like angular then you don't need to add underscore to each file enough if you are add get it Index file.

There are some options it's all about what kind of app you are building witch tool you are using.

Jorawar Singh
  • 7,463
  • 4
  • 26
  • 39