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

262
Visualizações
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 à 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