Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Then you just pre-build the page before publishing it. It's way cheaper as you do the work once, instead of every client being much slower because they have to do additional requests.


> Then you just pre-build the page before publishing it.

That's "using a programming language to solve the problem", isn't it?

> It's way cheaper as you do the work once, instead of every client being much slower because they have to do additional requests.

What work do client-side includes have to do other than fetching the page (which will get cached anyway)? It's less work to have a `<include-remote ...>` builtin than even a simple Makefile on the server.


It does not have to be a programming language on the server, no, unless you want to. The server can have a static site, that you build as you deploy it.

Fetching another resource is expensive. It's another round trip, and depending on many factors it could be another second to load the page. And if the HTML includes other nested HTML then it can be much slower.

This is the exact thing we try to avoid when building websites that perform well. You want as few chained requests as possible, and you want the browser to be aware of them as soon as possible, with the correct priority. That way the browser can get the important stuff needed to display content fast.

Including HTML client side for templating is just wasteful, slow and dumb from a technical standpoint.

Every client would have to do another request for each include. It would literally be many thousands of times slower(or worse) than doing it locally where the templates can be in memory as you render the pre-render the pages. You also save a ton of CPU cycles and bandwidth, by not serving more files with additional overhead like headers.


> It would literally be many thousands of times slower(or worse) than doing it locally where the templates can be in memory as you render the pre-render the pages.

Yeah, it's not. I'm doing client side includes and the includes get cached by the browser. I'm sure I would have noticed if my pages went from 1s to display to 1000s to display.

If you have a site/webapp with (say) twenty pages, that's only two extra requests for both header and footer.


An additional requests for html isn’t slow, and now I have to have a whole “build” process for something that is basically static. Not ideal


By "whole 'build' process", do you think something like a makefile or do you think something more advanced is required?

One drawback though would be that one indeed would have to maintain dependencies, which would be error prone beyond simply adding headers and footers... I wonder if one could (ab)use CPP [1] and its -M option to do that.

[1] https://gcc.gnu.org/onlinedocs/cpp/Invocation.html


Well, that very much depends on your definition of slow, doesn't it?

An additional request is another round trip. That can be very slow. Average TTFB on the internet in the US is ~0.7 seconds.

It's much faster to send it as part of the same request as you then don't have to wait for the browser to discover it, request it, wait for the response and then add it.

A build process does not have to be complicated, at all. If you can write HTML then using something that can simply read the HTML includes you wish existed and swap it with the specified filename is trivial.

Ofc, the idea has many other issues, like how to handle dependencies of the included HTML, how to handle conflicts, what oath to use and many more.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: