svelte:head remote js module not accessible,
See original GitHub issueWhen testing this code :
<svelte:head>
<title>Plotly</title>
<meta name="description" content="">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</svelte:head>
<script>
import { onMount } from 'svelte';
let data = [{
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
type: 'bar'
}];
onMount(() => {
Plotly.newPlot('myDiv', data, {}, {showSendToCloud:true});
});
</script>
<div>
<h1>Plotly Example</h1>
</div>
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
I get a “Plotly is not defined” error in the console… I can add the plotly script reference to the server.js file…and then the script works and my graph is rendered.
Oddly enough, if I copy and paste this into the : https://svelte.dev/examples#hello-world page…the graph will render. ???
Running on CentOS 7, tried Firefox 60.7.2esr and Chrome 75.0.3770.90 same effect.
On Svelte 3.12.1, using Rollup v1.25.1
Not a serious issue, new to Svelte just trying to get some old tools working. It looks like Svelte is going to power my next front end project. Love the project, keep up the good work guys.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How do I load an external JS library in Svelte/Sapper?
I hacked together a component to load external legacy JS libraries when I first started playing with Svelte2 and just refactored it to ......
Read more >Working with Svelte stores - Learn web development | MDN
Sometimes, your app state will need to be accessed by multiple components that are not hierarchically related, or by a regular JavaScript module...
Read more >Web Components with Svelte - This Dot Labs
Finally, we need to tell the compiler that we want to compile our Svelte components as custom elements. Go to vite.config.js and update...
Read more >A Beginner's Guide to SvelteKit - SitePoint
In other words, Svelte already compiles your code during the build process and the final bundle only contains JavaScript that your application ...
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 Free
Top 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
Hi Conduitry, thanks for the reply… I took your suggestion I ended up changing the code to this… works like a charm… I wanted to post a working solution for others…
In fact this solution has now helped me with several other external modules…
UPDATE !!! : I ended up changing the code again as I am using the “svelte-routing” module and the moment I navigated around it all got out of wack again… this solves my issues.
@viper6277 thank you for posting the solution! You’ve saved at least one dev a headache 😁