Search code examples
javascriptmaterializejspmsystemjs

Best way to load a globally usable library in jspm


I am new to jspm. I want to use materialize-css in my project. I think the ideal way of using it is that after installing with jspm (jspm install npm:materialize-css) using it must be something like this (in my index.html):

System.import("materialize-css");
System.import("app");

The question is what is the proper way of importing and using a library that is globally usable in all of my application and have css and javascript? Such as bootstrap, material-design-lite or materialize-css.


Solution

  • I think if you want to access the lib via the global/window object then you could import it in the index.html like you described it. But you should make sure that it is loaded before you import your app module:

    System.import("materialize-css").then(() => {
      System.import("app"); 
    });