Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does HTML5 not include a way of loading local HTML into the document?

I've thinking about this a lot lately. Why does HTML5 not really let you load HTML into your document to break up your HTML files?

It has support for nearly every other asset (images, videos, audio).

Yes we have iframes, embeds, and objects but they are sandboxed and don't follow the flow of the rest of the document.

I was thinking of something like:

<h2>My wonderful application</h2>  <include src = "leftPane.html" type = "text/html" />  <include src = "main.html" type = "text/html" />  <include src = "footer.html" type = "text/html" /> 

I would love for someone to explain this to me. In nearly every web application we make, we use some form of templating to break up our HTML, so why does HTML5 not just include it?

I'd appreciate your (flameless) thoughts.

Matt

like image 804
Matt Avatar asked Jul 29 '11 15:07

Matt


People also ask

How do I view local files in HTML?

The HTML input element of type="file" allows users to select one or more files from the local file system. Before HTML5, the purpose of the file input was solely to enable users to select files to be uploaded via a form.

How do I save a local HTML file?

Press CTRL+S. Right-click within the HTML document, click File > Save.

What is an HTML5 file?

HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HTML Living Standard.


1 Answers

As it turns out, this has come up in the WHATWG mailing lists: Client-side includes proposal: Shannon proposed exactly what you are saying, where the parser has to block while loading document fragments. Ian Hickson rejected it because the latency cost is too high. Besides, it's a simple feature that many web servers already provide, so it was deemed not worth the cost.

You may instead want to investigate using the seamless attribute of iframe, which causes a full document to be placed within the document but act like any block element (inheriting styles from the host document). I don't think it's supported by many browsers yet though.

like image 183
yonran Avatar answered Sep 21 '22 19:09

yonran