Home » Javascript » How can I use “Little Loader” to load js files with dependencies?

How can I use “Little Loader” to load js files with dependencies?

Posted by: admin November 1, 2017 Leave a comment

Questions:

I am trying to speed up the loading of DataTables.js. Currently the websites UI is available for almost 4 seconds before the DataTables’ features appear. One idea I had was to use a JavasScript loader. I did some research and found little-loader.js. The examples do not mention how to use it to load files with dependencies. How can I use it to load such files? Here is my code so far:

<script src="https://unpkg.com/[email protected]/dist/little-loader.min.js"></script>

<script>
window._lload("http://example.com/jquery-min.js", function (err) {
   // `err` is script load error.
   if( err === '' ) {
       window._lload("http://example.com/js/datatables-min.js", function (err) {
       //Maybe load other scripts
       } );
   }

} );
</script>
Answers: