Skip to content

Dynamically load CSS #449

@benpate

Description

@benpate

Currently, htmx parses <script> tags in a dynamically loaded HTML fragment, but it does not do the same for stylesheets. It would be great if we could make this work:

index.html

<script src="https://unpkg.com/htmx.org"></script>
<div hx-get="dynamic.html" hx-trigger="load"></div>

dynamic.html

<!-- Either load linked stylesheets -->
<link rel="stylesheet" href="test.css" />

<!-- Or parse inline styles -->
<style>
    .red {color:red;}
</style>

<b class="red">This is Red</b>
<b class="blue">This is Blue</b>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions