react-prism
react-prism copied to clipboard
Prism.js loaded every time the component renders
Trying the library and seeing the github example, every time a new PrismCode renders a request is made for the prism.js library.
Is there any way to load it only once?
Thanks
I believe it's due to their WebWorker API. Would you look at their docs too?
@tomchentw do you think worker-loader for webpack helps to have Prism be loaded w/ commonsJS? https://github.com/webpack/worker-loader
@chibicode I think so. You can load Prism that way and use expose loader in conjunction with it to make Prism globally accessible. In that case, you don't need to import Prism from a separate script tag.
Feel free to open a PR for updating these steps on README.md. Thanks!
Any update on this @chibicode @tomchentw?
@schickling could you try the latest example that's loading prism from cdn (not webpack)? https://github.com/tomchentw/react-prism/blob/cde34385be8ac5792d6974c115d2b731a8ce58c5/index.html#L11