Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading jQuery plugins and multiple scripts best practices

I'm currently looking for a way to load in multiple scripts/plugins without having a laundry list listed out in the header.

To simply have a load.js have everything load in would be very elegant to me.

$(function() {
    var scripts = ['scripts/jquery1.5.js','scripts/easing.js','scripts/scroll.js','scripts/main.js'];

    for(var i = 0; i < scripts.length; i++) {
        $.getScript(scripts[i]);
    }
})

I currently have something like this but can't get it to work for some reason. Any ideas?

like image 896
Tom Avatar asked Mar 01 '11 22:03

Tom


2 Answers

Have you looked at head.js?

like image 58
Jamie Treworgy Avatar answered Nov 12 '22 02:11

Jamie Treworgy


Here is my conclusion for head.js, I have done some benchmarks myself:

http://blog.feronovak.com/2011/03/headjs-script-is-it-really-necessary.html

It is subjective opinion and benchmarks are not by any means scientific.

like image 3
feronovak Avatar answered Nov 12 '22 03:11

feronovak