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

285
Views
Using JS function in another JS file

I have two JS files called main.js and load.js.

In main.js I have:

function removeItem() {
  alert('Item removed');
}
(function($) {  
    $(document).ready(function() {
    });
})(jQuery);

In load.js I have:

(function($) {  
    $(document).ready(function() {
      removeItem();
    });
})(jQuery);

My files are loaded in this order:

<script type='text/javascript' src='https://code.jquery.com/jquery-3.6.0.min.js?ver=3.6.0' id='script-jquery-js'></script>
<script type='text/javascript' src='url/wp-content/themes/theme/assets/js/main.js?ver=1.0' id='script-js'></script>
<script type='text/javascript' src='url/wp-content/themes/theme/assets/js/load.js?ver=1.0' id='script-load-js'></script>

It throws me an error:

removeItem() is not defined.

How can I use the function from main.js in load.js?

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!