-
Notifications
You must be signed in to change notification settings - Fork 24
Description
MR forces script loading to occur by either XHR or <script>. This is most easily reviewable in Require.makeLoader https://github.com/montagejs/mr/blob/master/browser.js#L290-L310
This works transparently for mopped & unmopped builds -- this is the intention and works for most cases. However, it does not provide an entry point for the developer to engage with the script loading process if they so choose.
Use Case
An application needs to load scripts from the file system. Node-webkit and cordova both offer enough access to the file system that the sources could be safely loaded directly from the device rather than from the server. If an application has 1000s of scripts, this can have a major effect on overall loading time. Further, any file loaded from the device can be removed from the appcache without affecting offline support.
Potential Solutions
- Add ability to supply custom Loader to
Require.makeLoader - Add delegate method to
Require.loadScriptto allow user to supply their own URL. For the file system use case, the developer could read the file, create a blob URL, and send that URL along to be assigned to the<script>