Utilizza una convenzione formale come require.js. Ad esempio, per caricare jquery-ui:
requirejs.config({
baseUrl: 'js/lib',
paths: {
// the left side is the module ID,
// the right side is the path to
// the jQuery UI file, relative to baseUrl.
// Also, the path should NOT include
// the '.js' file extension. This example
// is using jQuery UI located at
// js/lib/jquery-ui, relative to
// the HTML page.
jquery-ui: 'jquery-ui',
jquery-ui-autocomplete: 'jquery-ui-autocomplete'
}
});
e in seguito utilizzando il plug-in di completamento automatico:
require([ "jquery-ui-autocomplete" ], function( autocomplete ) {
autocomplete({ source: [ "One", "Two", "Three" ] }, "<input>" )
.element
.appendTo( "body" );
});
Riferimenti