import data from "https://example.com/data.json";Import attributes / notebook
Import attributes
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
import data from "https://example.com/data.json" with { type: "json" };import data from "https://example.com/data.json" with { type: "json" };import exampleStyles from "https://example.com/example_styles.css" with { type: "css" };
document.adoptedStyleSheets.push(exampleStyles);import text from "https://example.com/file.txt" with { type: "text" };<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<script type="module">
import data from "./data.json" with { type: "json" };
const p = document.createElement("p");
p.textContent = `name: ${data.name}`;
document.body.appendChild(p);
</script>
</head>
<body></body>
</html>const data = await import("./data.json", {
with: { type: "json" },
});