Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to intercept/bypass script loading #136

Open
tejaede opened this issue Jul 31, 2018 · 0 comments
Open

Add ability to intercept/bypass script loading #136

tejaede opened this issue Jul 31, 2018 · 0 comments

Comments

@tejaede
Copy link
Contributor

tejaede commented Jul 31, 2018

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

  1. Add ability to supply custom Loader to Require.makeLoader
  2. Add delegate method to Require.loadScript to 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant