A simple example

This example shows the basic usage of including CSS file and JavaScript file in your page.

Source

index.html

<html>
  <head>
    <title>with-simple-assets document</title>
    <link rel="stylesheet" href="css/style.css" />
    <script src="js/script.js"></script>
  </head>
  <body>
    <h1>Hey!</h1>
  </body>
</html>

css/style.css

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: yellow;
}

js/script.js

import { foo } from "./foo.js";

window.addEventListener("DOMContentLoaded", () => {
  foo();
});

js/foo.js

export function foo() {
  console.log("hello from foo.js");
}

Edit this page in GitHub