Skip to content

Use standard for and if with non-reactive variables #13232

Closed
@benmccann

Description

@benmccann

Describe the problem

If you do an {#if} check with a const then a $.if statement is output

Here's a silly REPL containing an {#if} and {#each} operating on a const:
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA5VTwW7bMAz9FUI7pAGcGm1ujp11n7BzVaCyJddEZcm16HSB4X8fZMWxvS3DdhIlPj6Sj1TPStTKseS5Z0bUiiXsW9OwiNG58Rd3UpoUi5izXVv4l9QVLTZ05IYT1o1tCXpwGqWCAcrW1rAJQTG1wjgktGZz4MbjC2scAZKqHWTw7J849eHg9NEp59EJbCYTHjbR5BbGfao2gddgwMNr8AzRP_A83uZ5_B-e_W2e_cTjj5dLx1oRuMp-onmDDDojVYlGycOshkTXaHH-fsnghaG2Uwdu0niW2qSdhkIL5zLOvIC7t9Z2DWfjHPovShTVRVjhRiMCHEJBqcZV6CVodFX7q2vqkTNAubj3OCwifDIsf6t6mP2c0rwjsmb5xGlKk5OBnMxOo3nnbI3xS-chIfwXpzVJobF4z_q7LWRHuJt1vVpZBghfwXRaQ7JE4HY7rOlEi2KnfjTCSCWzfkXxJ2hhDbVW-xYKq7VonBqVWUKP67jeq30_6biWKA5NLnWNsbxi0rjaX32j4rcKTCWewsBWZV3HGraTM5i_YxK-69iWFrnSWsn8_JeRc-qfKqr1uFj3gXFZQizxNFc795HGGsOCxn5BB7_TnT5ywyJWW4klKskSv-7Dy_ATQryOj4sEAAA=

Describe the proposed solution

Using just a standard if instead would result in smaller and faster code. The same holds for $.each vs for

Also, for very simple apps it might avoid pulling in functions like each and reconcile resulting in a smaller runtime. My site is actually simple enough that the only data I have is hard coded in the app and would actually fall into this category

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions