To use Vega-Embed directly in an HTML file without a build step, import vega, vega-lite, and vega-embed from a CDN like jsDelivr. Ensure you replace [VERSION] with the appropriate major versions (e.g., vega@5, vega-lite@5, vega-embed@6).
Use the vegaEmbed(container, spec) function, which returns a Promise that resolves to a result object containing the Vega view instance in result.view.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Import Vega & Vega-Lite -->
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
<!-- Import vega-embed -->
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
</head>
<body>
<div id="vis"></div>
<script type="text/javascript">
var spec = 'https://raw.githubusercontent.com/vega/vega/master/docs/examples/bar-chart.vg.json';
vegaEmbed('#vis', spec)
.then(function (result) {
// Access the Vega view instance as result.view
})
.catch(console.error);
</script>
</body>
</html>