I went a bit further with the dialog example using <details><summary>
The dialog can be opened by the user BEFORE JavaScript has finished loading.
Once JS loads, the state is synced, and all dialog features are restored (focus management, portal, etc.).