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

265
Vistas
Can't set $(element).innerText after including in-browser babel to a django project

The moment I included babel, the following snippet stopped working as before. Perhaps it's because of the absence of a module bundler. I need react just for one UI component.
index.js

document.addEventListener('DOMContentLoaded', () => {
  document.querySelector('#' + VIEWS.profile).innerText = 'profile'
})

index.html

<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="{% static 'network/index.js' %}"></script>

The querySelector query returns the target element when tested in console under the same execution context. Babel reports, You are using the in-browser Babel transformer. Be sure to precompile your scripts for production Moreover, babel makes it hard to debug js in the browser. Is there any way around this?

EDIT 1: moved the contents of index.js to the script tags
Problem persists, no change noticed.

EDIT 2: problem's cause identified
The event 'DOMContentLoaded' is dispatched before Babel compiles the javascript and appends it to the DOM. For the moment I am creating a custom event. Isn't there a way to listen for something like 'BabelCompilationComplete'?

about 4 years ago · Juan Pablo Isaza
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