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

250
Views
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 answers
Answer question

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 Report
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!