Skip to content

leaflet

The leaflet registry script. It loads https://unpkg.com/leaflet@1.9.4/dist/leaflet.js for the input of the example. Call useScriptLeaflet(input, options?) from @hamur/scripts/<library> in a component, or list it under scripts.registry.leaflet to load it on every page.

Config keyscripts.registry.leaflet
FunctionuseScriptLeaflet of @hamur/scripts/<library>
Input keysversion
Default triggermanual
Scripthttps://unpkg.com/leaflet@1.9.4/dist/leaflet.js
Hostsunpkg.com
Bundleyes: scripts.bundle: ["leaflet"]
Collection proxyno
Consentnone

Example

ts
import { defineConfig } from "hamur";
import scripts from "@hamur/scripts";

export default defineConfig({
  framework: "react",
  modules: [scripts],
  scripts: {
    registry: {
      leaflet: { version: "1.9.4" },
    },
  },
});

It loads when load() is called or when the trigger you pass fires. List leaflet in scripts.bundle and the build serves the file from your origin with a SHA-384 integrity (see Bundling). The script sends its own requests to the vendor.

Every key is checked when the config loads and again in useScriptLeaflet: a wrong value stops the build with a message that starts with scripts.registry.leaflet. The registry list is on the registry page, and the shared options are in Scripts.