Skip to content

EvanHahn/ScriptInclude

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScriptInclude

ScriptInclude allows you to asynchronously load script tags into the browser. I made it because I wanted a #include statement like other languages have, so I did my best to recreate that.

ScriptInclude aims to be tiny and easy to understand. There is no dependency management or anything.

It's meant to be minified and inlined, like so:

<!-- ... -->
<body>
  <!-- ... -->

  <script>

  // ScriptInclude, minified and inlined
  include=function(){ /* ... */ }

  // my stuff
  include('jquery.js', function() {
    include('main.js');
  });

  </script>

  <!-- ... -->

Some example usage

Include a single file

include('library.js', function() {
  // library.js has been loaded, now we can use it
});

Callbacks are optional.

Include multiple files

include('underscore.js', 'backbone.js', function() {
  // Underscore and Backbone are loaded in, let's go for it
});

You can include as many files as you want.

About

asynchronously load .js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •