Converting a variable url to a script in the header

When I use Bootstrap and jQuery, I Google the CDN and then just add the link element to my head section. I am working in a local environment instead of CodePen. I am working on Quote Machine now. Here is my scripts file:

$(document).ready(function() {
  var api =
    "https://api.forismatic.com/api/1.0/?
    method=getQuote&lang=en&format=jsonp&jsonp=?";

  $("#generateQoute").on("click", function() {
    $.getJSON(api, function(json) {
      $("#quote").html(json.quoteText);
      $("#author").html("<cite>-- " + json.quoteAuthor + "</cite>");
    });
  });
});

Can I put that variable in the head section of my html file, so I don’t have to declare a variable inside my script and jQuery function? If I can, what would I replace inside my getJSON method for the URL parameter? Thanks for reading.

Thanks for replying. I guess I phrased my question a little weird. When I imported jQuery and Bootstrap I used a CDN in a link tag.

<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-
      FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" 
      crossorigin="anonymous"></script>

<script type="text/javascript" src="scripts.js"></script>

Can I use the Forismatic API like this with just using a link tag that imports all the functionality?

Everything is clarified and now I understand. Thanks for your help @camperextraordinaire