DEV Community

Discussion on: What would the ideal web framework look like?

Collapse
 
terabytetiger profile image
Tyler V. (he/him)

and the compiled output will be HTML (Yes, actual HTML, not just a boilerplate)

Can you clarify what you mean by this? I'm not sure I understand it.

Collapse
 
siddharthshyniben profile image
Siddharth

Consider this component:

<script>
    let name = 'world';
</script>

<main>
    <h1>Hello {name}!</h1>
</main>

Enter fullscreen mode Exit fullscreen mode

If you run this through Svelte, you get this HTML as output:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1'>

    <title>Svelte app</title>

    <link rel='icon' type='image/png' href='/favicon.png'>
    <link rel='stylesheet' href='/global.css'>
    <link rel='stylesheet' href='/build/bundle.css'>

    <script defer src='/build/bundle.js'></script>
</head>

<body>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

It's basically a boilerplate. In my "ideal" framework, the h1 element would be there in the HTML (maybe statically embedded, if the framework is really good). This could speed up a little bit

Thread Thread
 
terabytetiger profile image
Tyler V. (he/him)

I see what you mean now - Something that outputs closer to Static Site Generators without being fully static 😊 That would be amazing!

Thread Thread
 
efpage profile image
Eckehard

Why not use a function h1("Headline")? This would be even quicker as it create a DOM element without rendering HTML. And as it is a function, it can be part of any algorithm you want.

Thread Thread
 
siddharthshyniben profile image
Siddharth

Yep, it would! I'm actually building a prototype of something like this.

Thread Thread
 
codinghusi profile image
Gerrit Weiermann

What about next.js?

Thread Thread
 
siddharthshyniben profile image
Siddharth

It sounds interesting, but I haven't used it, so I can't say much.