title: Using JavaScript library installed via npm in Django template
body: <p>I have rudimentary experience with JavaScript, centered around predominantly using JQuery. </p>
  
  <p>In a Django project I'm building, I typically import my JQuery code into a Django template like so: <code>&lt;script type="text/javascript" src="{{ STATIC_URL }}js/preloader.js"&gt;&lt;/script&gt;</code>. </p>
  
  <p>Now I need to use a JS library that's installed via <code>npm</code>. Specifically this one: <a href="https://github.com/brunobar79/J-I-C" rel="nofollow noreferrer">github.com/brunobar79/J-I-C</a>. It's job is to compress user uploaded on the client-side before uploading them to the server. E.g. I can do <code>target_img.src = jic.compress(source_img,quality,output_format).src;</code>. </p>
  
  <p>But how would I call this compress method in my template? </p>
  
  <p>As in, where/how do I import it? Should I dump all the library's code in a separate file and import it via <code>&lt;script type="text/javascript" src="{{ STATIC_URL }}js/JIC.min.js"&gt;&lt;/script&gt;</code>? </p>
  
  <p>If I were to do that, then why install the library via <code>npm</code> at all?</p>
  
  <p>Like I said, my knowledge in this domain is rudimentary. Would be great to get an illustrative example that clears my concept.</p>