Closed as not planned
Description
Describe the problem
Say I have a component with a bunch of markup rendered from a static array:
<script>
const episodes = [{name: 'foo', length: '10:00'}, /* ... 100 more episodes */];
</script>
<ul>
{#each episodes as episode}
<li>{episode.name} - {episode.length}</li>
{/each}
</ul>
This generates JS that looks something like:
function Component($$anchor) {
const episodes = [{ name: 'foo', length: '10:00' } /* ... 100 more episodes */];
var ul = root();
$.each(ul, 21, () => episodes, $.index, ($$anchor, episode) => {
// etc...
});
}
This has to do all the work of iterating through the array, and also create all the associated signals.
Describe the proposed solution
If a local variable is never mutated, svelte should detect that and generate something like the following:
$.from_html(`<ul><li>foo - 10:00</li></ul>`);
// large `episodes` array is not included in the generated code!
Importance
nice to have
Metadata
Metadata
Assignees
Labels
No labels