Is it recommended to use <link href="#"> or <script src="#"> with external addresses?

Asked

Viewed 135 times

1

I would like to know if there is any correct (or more efficient) way to use existing . css or . js files. If it is advisable to request external addresses or it is ideal to use within my application.

Example: Using bootstrap, it is best to download and put in my application (Content folder)

<link href="~/Content/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link href="~/Content/site.css" rel="stylesheet">
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/jquery.min.js"></script>
<link rel="stylesheet" href="~/Content/css1/font-awesome.min.css">

Or it is better to use via external address?

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  • The safest is for you to have within your application.

  • @Mayconf.Castro is there any reason behind this? Or just because making an external request makes it unsafe?

  • Greetings, Bruno, could you replace the images of your question with the code itself? Posting them in image form harms the search system of the site and reading the question of multiple users, as images are not displayed everywhere.

  • I think that at any time the external link can stay out of the air or something like that, so I always prefer to put inside my applications.

  • 6
  • The biggest gain you have using the files within the project and not with external links is that vc will never take the risk of a link of some file being broken due to a server crash for example.

  • @Andersoncarloswoss edited. About this duplicate, I had not found it in my research, but the answer there I believe to be the most complete.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.