Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!