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
Problems using "require" with two script-tags

I have a function loadDays() that should be called when my body section is loaded:

<body onload="loadDays()">

My loadDays() function looks like this:

<script>
    function loadDays() {  
        // Code
    }
</script>
      

Inside of loadDays() I need to access an excel-file.

So I added src="https://requirejs.org/docs/release/2.3.5/minified/require.js" to the <script> tag.

But then I recieved the following error:

Uncaught ReferenceError: loadDays is not defined at onload


Then someone gave me the hint to use two different <script> tags:

<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js">
    const Excel = require('exceljs');
</script>

<script>
    function loadDays() {       
        // Code
    }
</script>

But now I have the problem that it says:

Uncaught ReferenceError: Excel is not defined at loadDays

How can I solve this issue?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As an alternative, in your script you could use a 'DOMready' event :

https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event

window.addEventListener('DOMContentLoaded', (event) => {
    console.log('DOM fully loaded and parsed');
});

Everything inside this event will be executed once the full DOM is loaded

If you import well your script, that should do the trick

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