What is the difference, benefits, pros and cons of using following ways of including external scripts to Angular application (externalLib.js used in example):
Include script reference directly into
index.htmlfile via script tag:
<script src="../node_modules/jquery/dist/jquery.js"></script>Set path to library in
angular-cli.jsonfile inscriptsarray:
"scripts": [ "../node_modules/path/to/lib/externalLib.js"]Include
externalLib.jsfile in assets folder
In addition, does any of above methods support strong typing of library (i.e. automatic handling of externalLib.d.ts?
Thank you for help.
npm install @types/jquery --save-dev. If you look at your tsconfig.app.json it has"typeRoots": ["node_modules/@types"], this will tell the typescript compiler to use all your typings in that folder. Sidenote: often times when installing a typescript library, the types will be a dependency so you won't have to manually install, but since you are loading an external script, you most likely have to install the types manually