Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

339
Visualizações
Dynamic script activation fails with Blazor Server in Firefox

In a Blazor Server (.NET Core 6) application, I have this test html/head/script element:

<script type="text/plain" data-consent-category="google" defer>
    alert("Google Analytics loaded");
</script>

When a user presses a consent button, a piece of code is executed:

function ApplyPreferencesAbbreviatedCode() {
    let activatableScriptTags = document.querySelectorAll("script[type='text/plain']");
    activatableScriptTags.forEach(element => {
        let requiredCategory = element.getAttribute("data-consent-category");
        let clonedElement = element.cloneNode(true);
        clonedElement.setAttribute("type", "text/javascript");
        element.parentElement.insertBefore(clonedElement, element.nextSibling);
        element.remove();
    });
}

This works fine in Edge but does nothing in Firefox. How can I dynamically load scripts in a way that works in Blazor Server/Firefox (it should work with script elements with and without a src attribute).

Note: not having the defer attribute will cause the element to be stripped by Blazor Server (although it is supposed to not have any semantics when there is no src attribute as well).

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda