Skip to content

Conversation

liamcmitchell
Copy link
Contributor

  • Compile inline HTML with esbuild, allowing minification and sharing of constants
  • Add asset_inline helper to templates.ex
  • Refactor asset resolving

Before

  <body class="sidebar-closed">
    <script>

      try {
        var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}');

        if (settings.theme === 'dark' ||
           ((settings.theme === 'system' || settings.theme == null) &&
             window.matchMedia('(prefers-color-scheme: dark)').matches)
           ) {
          document.body.classList.add('dark')
        }
      } catch (error) { }
    </script>

After

  <body class="sidebar-closed">
    <script>(()=>{var t="ex_doc:settings";try{let{theme:e}=JSON.parse(localStorage.getItem(t)||"{}");(e==="dark"||(e==="system"||e==null)&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&document.body.classList.add("dark")}catch{}})();
</script>

Tests are passing locally

@josevalim
Copy link
Member

Pushed to main with assets. Thank you.

@josevalim josevalim closed this Dec 31, 2024
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants