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

111
Views
ES6 module loaded dynamically along with Fetched part doesn't execute when content is loaded again

I have a page that switches content using fetch API. Every content is accompanied with a js file. Some of them are type='module'. However although modules are working excellent during the first load, when I switch content (call a different fetch endpoint) and switch back again the corresponding script doesn't seem to work. When the whole page is changed (e.g. go to profile page and then again to main page) the scripts are working normally.

--- inside the main page the part that calls the content ---

...
    auth.fetch(partUri).then((resp) => {
            return resp.text().then(text => {
                
                $('.title > h2').text(titles[ch - 1]);

                $('#part-' + partNo).html(text);
                }
    
            });
          
    });
...

--- Inside the content's html file ---

...
<script> <--- this script is working after switching back
    new SimpleLightbox('.gallery-item a', {
        disableScroll: false
    });
</script>
<script type="module" src="js/part-3.js"></script> <--- this script is working only the first time
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!