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

268
Vistas
Import a JavaScript file into another JavaScript file that is imported into another file

I need to import a file that imports code from another file and then import that file into a final file that adds code to an HTML button. How can I do this? When I try with the following example below no code runs.

// file 1
export function someFunction() {
    // more code
}

// file 2
import {someFunction} from './file1';
export function otherFunction() {
    someFunction();
    // more code
}

// file 3
import {otherFunction} from './file2';
document.getElementById('some-button').onclick = otherFunction;

// in index.html 
<script type='module' src='./file3.js'></script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The solution is to have all the files be included in the index.html as type="module"

<script type='module' src='./file1.js'></script>
<script type='module' src='./file2.js'></script>
<script type='module' src='./file3.js'></script>
about 4 years ago · Juan Pablo Isaza Denunciar
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