Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

344
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda