taptapship / wiredep

Wire Bower dependencies to your source code.
MIT License
1.15k stars 142 forks source link

support async loading of scripts #205

Closed ktarplee closed 8 years ago

ktarplee commented 9 years ago

For asm.js code you need to load it with <script async src="foo.js"></script> so that Firefox will cache the code. It would nice if wiredep supported this functionality in some way.

stephenplusplus commented 9 years ago

Could you just use:

wiredep({
  fileTypes: {
    html: {
      replace: {
        js: '<script async src="{{filePath}}"></script>'
      }
    }
  }
});

?

ktarplee commented 9 years ago

I only want to async load a particular dependencies. It seems this would async load all dependencies (that would likely break things).

stephenplusplus commented 9 years ago

How about excluding it, and manually writing the script tag outside of the bower:js block?

ktarplee commented 9 years ago

That is how I am currently fixing it but it has negative rippling effects to the rest of the Gruntfile (for instance). I wonder if this is really a property of the script to be loaded as opposed to a property of the html file loading the script or the Gruntfile? Should the bower.json file include an indication that this is asm.js and then wiredep load it with async so that tools can cache it? I don't really like this idea... I think it should be explicit. I think the decision of when to load scripts sync vs async is application dependent.

eddiemonge commented 8 years ago

I don't really think this should be handled here. stephen's idea sounds right. Sounds like your gruntfile needs some slight tweaking to be able to handle that. Also, if you are using gruntfile to concat files then it would kill the async tag if you bundle it with other things anyway.