title: reference error: PDFJS is not defined when loading a pdf
body: <p>I am trying to use pdf.js to load pdf into a web application so that I can further extract information from the pdf file live. But I am getting this error with a very minimal example.</p>
  
  <p>I have tried wrapping the code in $(document).ready() as suggested in <a href="https://stackoverflow.com/questions/48647838/uncaught-referenceerror-pdfjs-is-not-defined-when-initialising-pdf-js?rq=1">Uncaught ReferenceError: PDFJS is not defined when initialising PDF.JS</a></p>
  
  <p>I am not able to access PDFJS in console either. </p>
  
  <p>Below is the code I am using (from <a href="https://www.sitepoint.com/custom-pdf-rendering/" rel="noreferrer">https://www.sitepoint.com/custom-pdf-rendering/</a>)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"/&gt;
      &lt;title&gt;PDF.js Learning&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="https://mozilla.github.io/pdf.js/build/pdf.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="https://mozilla.github.io/pdf.js/build/pdf.worker.js"&gt;&lt;/script&gt;
      &lt;script&gt;
      $(document).ready(function () {
      var url = "https://github.com/mozilla/pdf.js/blob/master/web/compressed.tracemonkey-pldi-09.pdf";
  
  // Asynchronous download PDF
  PDFJS.getDocument(url)
    .then(function(pdf) {
      return pdf.getPage(1);
    })
    .then(function(page) {
      // Set scale (zoom) level
      var scale = 1.5;
  
      // Get viewport (dimensions)
      var viewport = page.getViewport(scale);
  
      // Get canvas#the-canvas
      var canvas = document.getElementById('the-canvas');
  
      // Fetch canvas' 2d context
      var context = canvas.getContext('2d');
  
      // Set dimensions to Canvas
      canvas.height = viewport.height;
      canvas.width = viewport.width;
  
      // Prepare object needed by render method
      var renderContext = {
        canvasContext: context,
        viewport: viewport
      };
  
      // Render PDF page
      page.render(renderContext);
    });
    })
    &lt;/script&gt;
    &lt;canvas id='the-canvas'&gt;&lt;/canvas&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>