Skip to content

yupaul/multiloader.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

multiloader.js

Load multiple scripts into an HTML page.

Any script can also have multiple alternative sources - in case one fails, it can load from another source. Optional callback function is executed when all scripts finished loading.

multiloader(  
      // these are alternative versions, only one of them loads:
  ['https://a.com/my1.js', 'https://b.com/my1.js', 'https://c.com/my1.js'],
      // this loads second:
  'https://a.com/my2.js', 
      // this loads third, 3 alternative versions, only one of them loads:
  ['https://a.com/my3.js', 'https://b.com/my3.js', 'https://c.com/my3.js'],
  // ... can load more
  () => console.log('All Loaded!') //optional     
)  
// minimal, just load one script, the same as just:
// <script src="https://example.com/script.js"></script>
multiloader('https://example.com/script.js') 
// load one script, with one alternative source
multiloader(['https://example1.com/script.js', 'https://example2.com/script.js']) 

About

Load multiple scripts into an HTML page

Resources

Stars

Watchers

Forks