-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
How to load external assets only once accross isomorphic navigation? #373
Comments
Can you provide some example code? |
@rickysahu it's require a dynamic modules, you can use Something like that: export default class extends React.Component{
componentDidMount(){
require.ensure([], (require)=>{
someModule = require("some-npm-module");
someModule.init(this.someRefNode);
})
}
} |
@babakness currently you need to setup a custom middleware to serve additional static file chunks that webpack generates (also need a tweak for webpack config), using #310 yes we can use PS: I am working to make some demo, so everybody can use this. |
Dynamic imports will be ready for next |
Does this also relate to #738? |
What's the best way to load an external JS file only once across different pages and components between navigation events? For example i need the google maps js file in one specific component used across many pages. Currently im using <script..> but each time the component loads, it reloads the external js file.
Obviously multiple loads adds additional bandwidth, but more importantly when the js file reloads, it breaks gmaps
The text was updated successfully, but these errors were encountered: