2

Lately working with svelte in a project. The generated HTML uses Javascript with link and modulepreload:

<!doctype html>
<html>
<head>
    ...
    <link rel="modulepreload" href="./_app/immutable/entry/start.ed2a2ab5.js">
    <link rel="modulepreload" href="./_app/immutable/chunks/scheduler.8a566589.js">
    <link rel="modulepreload" href="./_app/immutable/chunks/singletons.a436eea2.js">
    <link rel="modulepreload" href="./_app/immutable/chunks/index.220c2c81.js">
    <link rel="modulepreload" href="./_app/immutable/entry/app.e682a49a.js">
    <link rel="modulepreload" href="./_app/immutable/chunks/index.95a0b3d5.js">
    <link rel="modulepreload" href="./_app/immutable/nodes/0.77b736d5.js">
    <link rel="modulepreload" href="./_app/immutable/nodes/2.87586eb9.js">
</head>
<body>
    ...
    <script>
        // some scripts here to use the preloaded module code.
    </script>
</body>
</html>

How do I declare in mymodule.libraries.yml so files can be displayed as this link format?

1
  • Libraries don't support arbitrary tags, just stylesheets and scripts. It's extendable if you're so inclined, but it may be (quite a bit) easier to use hook_page_attachments_alter() and add html_head items instead, e.g. drupal.stackexchange.com/questions/301098/… Commented Jan 11, 2024 at 16:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.