You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have components that combine Alpine.js for interactivity and HTMX for dynamic loading. These components contain both markup and their Alpine.js initialization code with proper CSP nonces.
The Problem
Initial page load: Everything works perfectly. CSP with nonces allows the inline scripts.
Loading via HTMX: CSP blocks the exact same inline scripts, even with valid nonces.
Example of what works on initial load but fails with HTMX:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The Setup
I have components that combine Alpine.js for interactivity and HTMX for dynamic loading. These components contain both markup and their Alpine.js initialization code with proper CSP nonces.
The Problem
Example of what works on initial load but fails with HTMX:
Current Workaround
I had to split the components:
This works but breaks component encapsulation - users need to remember to initialize the script part separately.
Questions
Would love to hear your thoughts and experiences!
Beta Was this translation helpful? Give feedback.
All reactions