gcorne / wp-react-boilerplate

Get started with using React in a WordPress plugin
129 stars 27 forks source link

Proper way to go with the scripts #10

Open marcinszpanowski opened 7 years ago

marcinszpanowski commented 7 years ago

It's more a question than an issue, but I still can't figure it out. I know that bundling everything is the only way to go in case of decoupled apps, but are you sure it's a good idea in case of WordPress?

I think that it would work pretty awesome when we have only 1 React powered app in our WP dashboard, but what happens when for an instance we have 3 (or 5) plugins powered by React? Does it mean that we are loading (at least) React and ReactDOM 3 or 5 times? Wouldn't the way mentioned in "Working in the browser" section be better in WordPress specific case?

I was thinking that while using wp_enqueue_script's 'handle' and 'deps' properly we can ensure that React and ReactDOM are loaded only once.

I'm really not sure, just trying to start a discussion. What are your thoughts?

PS. Awesome work btw!