Search code examples
javascriptdependency-injectionrequirejspolymeramd

Dependency injection with HTML imports


Having a lot fun with Polymer lately and I was wondering if there was a way I could swap requirejs for HTML imports without achieving namespace pollution. In other words is it possible to do dependency injection with HTML imports?


Solution

  • Dependency injection using HTML-imports is possible, but when it comes to namespace pollution you will unfortunately need to address that manually, as all scripts in the HTML5-imports are run in the same scope as the rest of your js code.