script.js icon indicating copy to clipboard operation
script.js copied to clipboard

Question about usage

Open kamov opened this issue 8 years ago • 2 comments

I have one minified files vendor.js with all third party script like jquery, bootstrap, etc.. Then I have one main.js files with custom script.

Using your plugin it this can be loaded like:

$script('path/to/vendor.js', 'vendor', function() {
    $script('path/to/main.js', 'main');
});

Can I use this way or is better separate vendor files?

Thanks

kamov avatar Mar 13 '17 11:03 kamov

You can use $script.order as well. It's not really documented but it works just as expected. For example:

$script.order(['path/to/vendor.js', 'path/to/main.js'], function () {
    // callback logic
});

boye avatar Mar 13 '17 12:03 boye

@boye thanks.. However my questions is another. Performance change if I load multiple files or just one single file? Maybe multiple files is loaded more fast since is loaded in parallel? Since I could just load one main file vendor + main for all pages, I could just use something like this:

var r = document.getElementsByTagName( "script" )[ 0 ], s = document.createElement( "script" ); s.src = 'all.js'; r.parentNode.insertBefore( s, r );

kamov avatar Mar 13 '17 13:03 kamov