Can i run Svelte fully as a CDN? #15658
Answered
by
brunnerh
struckchure
asked this question in
Q&A
-
I want to have this similar setup i have in VueJs, like this <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue 3</title>
</head>
<body>
<div id="app">
<p>
<span v-for="name in names" :key="name">{{ name }} </span>
</p>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script type="module">
const { createApp, ref } = Vue;
createApp({
data() {
return {
names: ["bola", "ade", "kemi"],
};
},
}).mount("#app");
</script>
</body>
</html> Is it possible? Because, i haven't been able to find a work around. |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Apr 1, 2025
Replies: 1 comment 3 replies
-
You would have to import the Svelte compiler, compile the component code and then mount the result. This would be rather involved and also slow, so I definitely do not recommend doing this. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No, not for Svelte 5, which no longer bundles everything.
Resolving all the imports necessary is a huge pain.
Would probably look similar to this: