I'm having trouble with javascript thiry-party
See original GitHub issueI’m learning a lot with react
but I’m having a difficulty with javascript third-party.
I need to embed a javascript Snap.svg to my homepage npm install snapsvg
(detail: https://github.com/adobe-webplatform/Snap.svg)
The way to import snapsvg
is by using this code:
const Snap = require(`imports-loader?this=>window,fix=>module.exports=0!snapsvg/dist/snap.svg.js`);
But this occurs a following error:
Module not found: 'imports-loader' in ...
I installed imports-loader
and it does not work.
What is another alternative without using eject
?
npm ls react-scripts
: react-scripts@0.9.5
node -v
: v7.7.3
npm -v
: 4.4.1
Operating system
: macOS Sierra
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Loading Third-Party JavaScript - web.dev
When scripts in third-party iframes take a long time to run, they can block the main thread delaying other tasks from running. These...
Read more >Debugging and Fixing Common JavaScript Errors Third Party ...
Here's what you'd learn in this lesson: Inspecting a code error, Todd determines a bug is occurring due to a third party vendor's...
Read more >Things to Know (and Potential Dangers) with Third-Party Scripts
A third-party script might have unintended consequences · Overwriting your variables · Creating unnecessary risks by using eval · Changing your ...
Read more >Run a piece of JavaScript as soon as a third-party script fails ...
We want to run some code after the browser finishes attempting to load a third-party script, so we can check whether it loaded...
Read more >Running Third-Party JavaScript - YouTube
Adopt the right emerging trends to solve your complex engineering challenges at QCon London March 27-29, 2023. Get practical inspiration and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi! We don’t support Webpack-specific syntax like this. Since they don’t provide a CommonJS entry point, your best bet is to:
snap.svg-min.js
into yourpublic
folder (preferably with a version, e.g.snap.svg@0.5.1-min.js
).public/index.html
and add<script src="%PUBLIC_URL%/snap.svg@0.5.1-min.js"></script>
to its<head>
.const Snap = window.Snap;
in any file where you want to use it, and you’re good to go.You can also ask them to provide a CommonJS entry point that doesn’t require fiddling with Webpack.
Hope it helps!
Hi @gaearon,
I saw the same problem with @Tectract . Below is the code of browserSolc https://github.com/ericxtang/browser-solc I have to sleep 1 second and everything is ok. So weird 😦 I downloaded and added to header of html file
<script src="%PUBLIC_URL%/browser-solc.min.js"></script>