Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile inline HTML with esbuild #1991

Closed
wants to merge 1 commit into from

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