Using client-side libraries with Atom


One thing that I’ve struggled with for a bit is how to include 3rd party client libraries in a package. For instance, I’m writing a package currently that I want to use handsontable with. It’s a fairly standard javascript library that has three basic requirements.

  1. Add a div with a certain ID to the page
  2. Include the stylesheet
  3. Include the main javascript file

The first item is no problem, obviously. The second, I assume, is just adding @import (inline) handsontable.css to the package’s LESS file.

The last item is the real kicker. My instinct is to just require the javascript file, but I’m really not sure if that’s the correct way to go about it. First off that requires altering the library such that it’s common-js compatible. Aside from that though, is requiring even the best way to go about it? I suppose I could add a script tag on the document fragment I create before adding it to the view, but I haven’t experimented with that yet.

Does anyone else have experience doing something like this? If so, could you point me to an example?