react-native-webview / react-native-webview

React Native Cross-Platform WebView
https://github.com/react-native-community/discussions-and-proposals/pull/3
MIT License
6.31k stars 2.96k forks source link

Allow WebView loading of JavaScripts from local (file://) #3365

Closed InnovateAsterisk closed 3 weeks ago

InnovateAsterisk commented 3 months ago

Is your feature request related to a problem? If so, Please describe. We would like to be able to load JavaScript Libraries like JQuery etc directly from local assets of the project rather than the CDN location.

Typically we have the webview navigate to say https://example.com/index.php, this serves custom content from our server. However we make use of various JS libraries. eg <script src="https://code.jquery.com/jquery-3.7.1.slim.min.js"></script>, however we cannot load the scripts with file://.. /jquery-3.7.1.slim.min.js even if allowFileAccess is set to true as the base URL is not set to file:// (as per https://github.com/react-native-webview/react-native-webview/issues/1786)

We feel that this would greatly improve our user experience as the load time and network resources would be dramatically reduced.

Describe the solutions you came up with For now we can only load via the network. We could possibly look at using a service worker, and implement fetch cache, but this would not help the first load.

Additional context We are busy converting an existing Android & iOS apps, to a single React Native App, and both Android and iOS have mechanisms for intercepting the url being loaded and can serve a local resource in its place.

github-actions[bot] commented 1 month ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically