Skip to content

Initial render to html file #3299

@davidcallanan

Description

@davidcallanan

Firstly, this feature could already exist, but after digging for a while I couldn't find it. I asked a question on stackoverflow

Is your feature request related to a problem? Please describe.

Svelte is compiled to both js and css, but not to a html file with the initial render. This means that the initial render has to be performed through JavaScript.

Problems with this:

  • Slower load time
  • Negative SEO impact
  • Potential negative accessibility impact
  • Browsers without JavaScript won't see anything, even if the page is mostly static

Describe the solution you'd like

I'd like the ability to also generate a html output which contains the initial render, and contains a link and script tag to the js and css (this could be configurable). In this situation, the initial render code should be removed from the javascript, and all that's left is the dynamic code.

Describe alternatives you've considered

  • Creating the static parts of the website inside the index.html file and only using Svelte for the dynamic parts. This would be very difficult to do and prevents me from using Svelte for any of the static parts. The dynamic parts would also still not have an initial html render which still has the issues described above, but at least it's better.
  • Switching to another framework such as Next.js or react static or something else. These all have at least one of the following problems which prevents me from using them:
    • Requires a runtime (which Svelte doesn't)
    • When compiled, none of the component-scoped javascript is available at runtime (which means adding hamburger menus, etc, is as difficult as using no framework)

How important is this feature to you?

Possibly important. If my website(s) grow, I don't want to have the issues I described above, but with a small website, it's not the end of the world for now.

And I don't believe this feature would be particularly difficult to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions