2

To tackle some touch-related problems I have written a script in app.js to reopen and enhance the EventDispatcher. The script is pretty long and contaminates the normally so clean app.js.

So I'd like to have my script in a seperate file and than somehow be imported in app.js. What in your opinion is the best (cleanest) way to do this?

FYI I'm using Ember CLI

Baukereg
  • 119
  • 1
  • 4

1 Answers1

1

I would place the script in file in in public/assets/js and load the script using Modernizr.load (Modernizr's implementation of yes nope) like this inside of script tags just before the closing body tag of your index.html file. In this situation, you could use Modernizr.touch to detect for touch event support on the user's device and, if present, load the touch polyfill/script.

Alternatively, place the file in the same place and load the script inside an if statement using $.getScript(url) in an initializer or the application view.

In both situations the script will not be imported into app.js but will still be loaded and ran.

Community
  • 1
  • 1
Duncan Walker
  • 2,182
  • 19
  • 28