By Kevin Hou
2 minute read
I am working on getting some neat, open-source Javascript libraries ported into my website. I'm trying to teach myself how to incorporate the plethora of user contributed libraries into my site. Over the summer, I taught myself how to use NPM dependencies — elegant packages of Javascript code that would perform preset functions. With the millions of NPM packages out there, I wanted to use it in my own site.
Unfortunately, I haven't been able to build a compiler that would allow me to use NPM dependencies in my code. I'm still interested in using other people's code in my apps so I've resorted to Javascript libraries. I came across a really cool one called TheaterJS. Here's a quick demo.
Turns out, the steps to import Javascript libraries are very straightforward and simple.
<head> of your HTML file like so:1<script src="path/to/library/TheaterJS-2.0.1/dist/theater.min.js"></script> <!-- TheaterJS -->
2
1theater
2 .addActor('kevin', { speed: 0.6, accuracy: 0.7 })
3 .addScene('kevin:Kevin Hou', 2000)
4 .addScene('kevin:Welcome!', 1000)
5 .addScene('kevin:Kevin Hou', 2000)
6 .addScene(theater.replay.bind(theater))
7
Hope this helped!