Comment by mixmastamyk
5 days ago
I recently learned the object tag can do what I wished for in the 90s... work as an include tag:
<object data="footer.html"></object>
Turn your back for twenty-five years, and be amazed at what they've come up with! ;-)
Should reduce a lot of boilerplate that would get out of sync on my next project, without need for templating.
Hey, I need to try this out, so it is like iframe except the frame part and all its issues?
Unfortunately that will require the client to make additional web requests to load the page, effectively doubling latency at a minimum.
A few extra <object> in a blog post is a worthwhile tradeoff, if you're literally using raw HTML.
- HTTP/1.1 (1997) already reuses connections, so it will not double latency. The DNS lookup and the TCP connection are a high fixed cost for the first .html request.
- HTTP/2 (2015) further reduces the cost of subsequent requests, with a bunch of techniques, like dictionary compression.
- You will likely still be 10x faster than a typical "modern" page with JavaScript, which has to load the JS first, and then execute it. The tradeoff has flipped now, where execution latency for JS / DOM reflows can be higher than network latency. So using raw HTML means you are already far ahead of the pack.
So say you have a 50 ms time for the initial .html request. Then adding some <object> might bring you to 55 ms, 60 ms, 80 ms, 100 ms.
But you would have to do something pretty bad to get to 300 ms or 1500 ms, which you can easily see on the modern web.
So yes go ahead and add those <object> tags, if it means you can get by with no toolchain. Personally I use Markdown and some custom Python scripts to generate the header and footer.
Yes, I’d add that not merely “raw html” but a file on disk can be served directly by Linux without context switches (I forget the syscall), and transferred faster than generation.
2 replies →
Sounds like premature optimization for a simple page. If the objects are sized their regions should be fillable afterward without need to resize and be cached for subsequent access.
The other solutions are even easier and don’t double latency.
> be cached for subsequent access.
So now you need to setup cache control?
4 replies →
I didn't know you could use object tags in that way! Thanks. That seems like a great solution if you're cool with an extra request
Couldn't you sort of do that using server side includes back en the 90s? Assuming that your web server supported it.
Yes, and a Makefile was an option as well. But an include tag was a no-brainer not long after html was invented. Especially after img, link, applet, frame, etc were implemented.