title: How to destroy PDFJS object?
body: <p>I need functionality for book library and for that I have used:</p>
  
  <ul>
  <li><p><em>Turn.js</em>, which is used for flipbook effect (only 3rd release working, 4th release not working with it, if someone have similar functionality with 4th release of turn.js, then please share your code).</p></li>
  <li><p><em>pdf.js</em>, which converts PDF to HTML on client side</p></li>
  </ul>
  
  <p><a href="http://www.maxims6n.bget.ru/pdf_books/demo_21.html" rel="noreferrer">This</a> is a reference link, that I have followed.</p>
  
  <p>I have modified one function for using that script dynamically, which adds PDF's path into that function and according to that link, books open in popup.</p>
  
  <p>Here is the JavaScript function for that:</p>
  
  <pre><code>function display_book(path){
  
      var url = path;
      PDFJS.disableWorker = false;
  
      PDFJS.getDocument(url).then(function(pdfDoc) {
          numberOfPages = pdfDoc.numPages;
          pdf = pdfDoc;
          $('#book').turn.pages = numberOfPages;
  
          $('#book').turn({acceleration: false,
              pages: numberOfPages,
              elevation: 50,
              gradients: !$.isTouch,
              // display: 'single',
              when: {
                  turning: function(e, page, view) {
  
                      // Gets the range of pages that the book needs right now
                      var range = $(this).turn('range', page);
  
                      // Check if each page is within the book
                      for (page = range[0]; page&lt;=range[1]; page++) {
                          addPage(page, $(this));
                          //renderPage(page);
                      };
  
                  },
  
                  turned: function(e, page) {
                      $('#page-number').val(page);
  
                      if (firstPagesRendered) {
                          var range = $(this).turn('range', page);
                          for (page = range[0]; page&lt;=range[1]; page++) {
                              if (!rendered[page]) {
                                  renderPage(page);
                                  rendered[page] = true;
                              }
                          };
                      }
                  }
  
              }
          });
  
  
          $("button.close").click(function(){
              //code for destroy pdfjs object
              $(".modal").css({"display":"none"});
          });
      });
  }
  </code></pre>
  
  <p>on that popup close event, I want to destroy object of PDFJS (to release memory). In this code turn.js 3rd released version is used, and if I replace that version with 4th release then code doesn't work.</p>