cool little chunk of code, thanks for sharing. I did something like this for sets of trimpath templates (js/html templates), never thought to do it for scripts. Nice.

- Jack

Eric Garside wrote:
If you get the developer build, each of the files is separated out
into a: ui.core.js, ui.draggable.js, etc format. If you want to add a
bit of spice:

$.uinclude = function(){
    var scripts = ['core'], counter, loaded = 0;
    scripts.push.apply(this, arguments);
    counter = scripts.length;
    $.each(scripts, function(){ $.ajax({ type: "GET", url: '/path/to/
jqueryui/ui.' + this + '.js', success: function(){ loaded++; if
(loaded == counter) $('body').trigger('ui-included'); }, dataType:
"script", cache: true });
}
// Example Usage
$('body').bind('ui-included', function(){
    // Triggered when your UI scripts are included
});

$.uinclude('draggable', 'resizable', 'tabs');

On Apr 3, 1:36 pm, Brendan <bcorco...@gmail.com> wrote:
Hi,

I'm looking at including jQuery UI in a project I am working on, but
one of my concerns is the large size of the full file.

I was wondering if there is something easy or built in that would
allow me to load only which jQuery UI plugins/effects I need on a
particular page.

So, something like:

loadUI({"core","accordion"});

Does that make sense? And each file would be separate on the server,
so they get cached. (like individual <script> tags loaded, without
going through all that hassle)


Reply via email to