2

Should I be shying away from including script file inclusions in my index.html files in angular 4?

I asked a question not to long ago for getting jquery-ui to work in an angular 4 app. One answer I received suggested that I include the script file in the index.html file.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

In my searching of the internet I have found many examples like this, but shouldn't we be using the .angular-cli.json and package.json file to achieve this via bootstrapping?

Is it bad practice to use file inclusion via index.html for npm available files or is either way fine? Or is there a use case to have them in both places?

3
  • For future reference, codereview.stackexchange.com is better suited for such questions Commented Aug 4, 2017 at 19:05
  • @Vandesh just joined the community. Did not know it was a thing! Thanks. Commented Aug 4, 2017 at 19:07
  • 1
    How is that forum better suited for this question? This is not a style or "how to make my code better" question but rather a "how does the CLI do this" question. Commented Aug 4, 2017 at 19:18

1 Answer 1

5

If you are using the Angular-cli, then the recommended practice is documented here:

https://github.com/angular/angular-cli/wiki/stories-global-scripts

It involves updating the angular.cli.json file:

"scripts": [
  "global-script.js",
],
Sign up to request clarification or add additional context in comments.

1 Comment

YOU JUST SOLVED MY OTHER ISSUES TOO!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.