-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix browser initial loading performance (#1568)
* Fix browser initial loading performance * Update test Co-authored-by: Ibrahim Taveras <ibrahimtaveras00@gmail.com>
- Loading branch information
1 parent
106696f
commit f1bb1ae
Showing
4 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Device from '../util/Device'; | ||
import RNFS from 'react-native-fs'; | ||
|
||
const EntryScriptWeb3 = { | ||
entryScriptWeb3: null, | ||
// Cache InpageBridgeWeb3 so that it is immediately available | ||
async init() { | ||
this.entryScriptWeb3 = Device.isIos() | ||
? await RNFS.readFile(`${RNFS.MainBundlePath}/InpageBridgeWeb3.js`, 'utf8') | ||
: await RNFS.readFileAssets(`InpageBridgeWeb3.js`); | ||
|
||
return this.entryScriptWeb3; | ||
}, | ||
async get() { | ||
// Return from cache | ||
if (this.entryScriptWeb3) return this.entryScriptWeb3; | ||
|
||
// If for some reason it is not available, get it again | ||
return await this.init(); | ||
} | ||
}; | ||
|
||
export default EntryScriptWeb3; |