Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import HTML #10470

Closed
trymeouteh opened this issue Jul 10, 2024 · 2 comments
Closed

Import HTML #10470

trymeouteh opened this issue Jul 10, 2024 · 2 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@trymeouteh
Copy link

What problem are you trying to solve?

A simple way to import HTML into another HTML file

What solutions exist today?

Using server side languages like PHP

How would you solve it?

Creating a new HTML tag called <import>

Here is some example code...

index.html

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>Hello World</title>
	</head>
	<body>
		<h1>Hello World</h1>

		<import src="footer.html">
	</body>
</html>

footer.html

<footer>
	<a href="#">Link A</a>
	<a href="#">Link B</a>
	<a href="#">Link C</a>
</footer>

How index.html it will render in the browser

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>Hello World</title>
	</head>
	<body>
		<h1>Hello World</h1>

		<footer>
			<a href="#">Link A</a>
			<a href="#">Link B</a>
			<a href="#">Link C</a>
		</footer>
	</body>
</html>

Anything else?

When browsers parse a HTML file and come across an import tag, it will need to stop loading the rest of the page until it fetches the HTML file that is stated in the src attribute. If it cannot find the file, it will give a 404 error in the browser console and continue on loading the rest of the HTML.

All the work will be done client side

@trymeouteh trymeouteh added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Jul 10, 2024
@nektro
Copy link

nektro commented Jul 10, 2024

https://www.w3.org/TR/html-imports/ + https://github.com/wicg/webcomponents/

this was already a thing and eventually discontinued. those links and related repos explain the rationale

@domenic
Copy link
Member

domenic commented Jul 11, 2024

Dupe of #2791.

@domenic domenic closed this as completed Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

3 participants