<terminal>
/**
*    @Author: Arash Karimzadeh
*    @Email: me@arashkarimzadeh.com
*    @Desciption: Here, I post some of my recent
*    researches. Also you can see my code projects.
*/  
Ajax C # Chrome CMS dateNet Design Patterns includeMany JavaScript jBind Joomla jQuery Plugin rails ror RubyOnRails SQLite xul

+ All tags

Content View Hits : 178451
Bookmark and Share
includeMany (jQuery Include CSS, JS, HTML Plugin) PDF Print E-mail
Written by Arash Karimzadeh   
Wednesday, 18 February 2009 16:19

includeMany is jQuery plugin for including many external JavaScript, CSS and HTML files simultaneously in runtime. This plugin provides callback for each of the files and in addition there is finallyCallback which will be raised after all files are loaded and all callbacks are done.
This extra callback guarantee that every files are loaded and available to use.

By this plugin you can use JavaScript to include other js and css files. You can also load other files such as html or a remote page using an HTTP GET request.

Download includeMany

Current version is 1.2.2
You can get it from here.

includeMany

  1. Formats
  2. Parameters
  3. Examples & Downloads
  4. Sample File

Formats

$.include(files,[finalCallback]);
$.chainclude(files,[finalCallback]); available in v.1.2.0 and +

*read more about this functionality here.

Parameters

  • files

Can be
  1. A single file such as 'fileurl'
  2. List of files such as ['fileurl1','fileurl2',...,'fileurln']
  3. Key/value object of files such as {'fileurl1':callback,'fileurl2':callback,...,'fileurl2':callback}
  • finalCallback [function] optional

Is a function which will be called after all files are loaded and all callbacks have been called.

Does it support Synchronous loading?

Yes, by using the $.chainclude() you can load js and css files in sequence. read more about it here.

Examples & Downloads

  • The simplest format is including one file as below
    1. $.include('script1.js');
     
    this will include script1.js
  • You can add finallyCallback to the above example so will be called when the script is loaded
    1. $.include('script1.js',functionName);
     
    this will include script1.js and call functionName. This function can be anything like this:
    1. function functionName(){
    2. $.trace('some loading is done!!!');
    3. }
     
  • You can include multiple files:
    1. $.include( ['styles/css2.css','scripts/js2.js'] ,someOptionalFunction);
     
    You can avoid someOptionalFunction.
  • You can define a callback for each includedFile
    1. $.include(
    2. {
    3. 'script1.js':function(){ /*something*/ },
    4. 'script2.js':function(){ /*something*/ },
    5. 'somecss.css':null,
    6. 'temp2.html':function(data){alert(data)}
    7. }
    8. );
     
  • You can also define a finallyCallback so, after all files are loaded and all callbacks are called, this function will be fired.
    1. var globalCallback= function(){
    2. alert('all files are loaded!!!');
    3. }
    4. $.include(
    5. {
    6. 'script1.js':function(){ /*something*/ },
    7. 'script2.js':function(){ /*something*/ },
    8. 'somecss.css':null,
    9. 'temp2.html':function(data){alert(data)}
    10. }
    11. ,globalCallback
    12. );
     

    atlast is our finallyCallback function.

Sample File

You can download the sample file here.

Tags: includeMany | jQuery | Plugin

Comments
Add New Search
+/-
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
Please input the anti-spam code that you can read in the image.
replica watches  - replica watches   |2010-02-27 06:38:30
1.genanv0227
|Replica Handbags|
|Replica Louis Vuitton|
|Replica Watches|
|replica handbags|
|Louis vuitton handbags|
|Replica Handbags|
|replica watches|
|Hermes Handbags|
|Replica Sunglasses|
|Cheap Sunglasses|
|Designer Replica Sunglasses|
2.
|Breitling watches
Breitling replica watches
Replica Breitling
Classic Watches
AIR WOLF Watches
AVENGER SEAWOLF Watches
AVENGER SKYLAND Watches
BENTLEY GMT Watches
BENTLEY MOTORS Watches
CERTIFIE Watches
CHRONO AVENGER Watches
CHRONO COCKPIT Watches
CHRONO SUPEROCEAN Watches
CHRONOMAT Watches
CHRONOMATIC Watches
CO AXIAL Watches
COCKPIT Watches
COLT AUTOMATIC Watches
COLT GMT Watches
COLT OCEANE Watches
COLT QUARTZ Watches
Emergency Mission Watches
MONTBRILLANT Watches
NAVITIMER Watches
SKYRACER Watches
SUPER AVENGER Watches
SUPEROCEAN CHRONOMATIC Watches
SUPEROCEAN HERITAGE Watches
SUPEROCEAN HERITAGE 46 Watches
SUPEROCEAN HERITAGE CHRONOGRAPHE Watches|
3.
|replicat tiffany
tiffany jewelry
Repli...
Anonymous   |2010-02-23 12:03:08
No matter how large wow power levelingor small the event, the prospect of planning an occasion for however many people wow power levelingcan seem a daunting one. Where is the right place to start when you are looking to plan a successful event? .With these handy hints you will learn effective methods for planning successful events for just about any occasion, from intimate gatherings to large conferences.aion power levelingThe first task is to clearly establish the purpose of your event. aion goldThis may sound like a perfectly trivial task, cheap wow power levelinghowever if you do not clearly define the focus of your event then you risk to possibility of spending your money inefficiently. buy wow power levelingAs an example, you may ask yourself whether the event us going to be a celebration? Or is it going to be a fundraiser? You will also want to consider what sort of atmosphere would be appropriate for your event. cheap .If your event is going...
replica watches  - replica watches   |2010-02-08 05:30:07
1.genanv0208
|Replica Handbags|
|Replica Louis Vuitton|
|Replica Watches|
|replica handbags|
|Louis vuitton handbags|
|Replica Handbags|
|replica watches|
|Hermes Handbags|
|Replica Sunglasses|
|Cheap Sunglasses|
|Designer Replica Sunglasses|
2.
|Breitling watches
Breitling replica watches
Replica Breitling
Classic Watches
AIR WOLF Watches
AVENGER SEAWOLF Watches
AVENGER SKYLAND Watches
BENTLEY GMT Watches
BENTLEY MOTORS Watches
CERTIFIE Watches
CHRONO AVENGER Watches
CHRONO COCKPIT Watches
CHRONO SUPEROCEAN Watches
CHRONOMAT Watches
CHRONOMATIC Watches
CO AXIAL Watches
COCKPIT Watches
COLT AUTOMATIC Watches
COLT GMT Watches
COLT OCEANE Watches
COLT QUARTZ Watches
Emergency Mission Watches
MONTBRILLANT Watches
NAVITIMER Watches
SKYRACER Watches
SUPER AVENGER Watches
SUPEROCEAN CHRONOMATIC Watches
SUPEROCEAN HERITAGE Watches
SUPEROCEAN HERITAGE 46 Watches
SUPEROCEAN HERITAGE CHRONOGRAPHE Watches|
3.
|replicat tiffany
tiffany jewelry
Repli...
ReplicaHandbags  - replica Handbags   |2010-01-29 07:17:03
aqian100129
1.
|Replica Handbags|
Replica Louis Vuitton|
Replica Watches|
replica handbags|
Louis vuitton handbags|
Replica Handbags|
replica watches|
Wholesale Replica Handbags|
Hermes Handbags|
2.
|Breitling watches|
Breitling replica watches|
Replica Breitling|
Classic Watches|
AIR WOLF Watches|
AVENGER SEAWOLF Watches|
AVENGER SKYLAND Watches|
BENTLEY GMT Watches|
BENTLEY MOTORS Watches|
CERTIFIE Watches|
CHRONO AVENGER Watches|
CHRONO COCKPIT Watches|
CHRONO SUPEROCEAN Watches|
CHRONOMAT Watches|
CHRONOMATIC Watches|
CO AXIAL Watches|
COCKPIT Watches|
COLT AUTOMATIC Watches|
COLT GMT Watches|
COLT OCEANE Watches|
COLT QUARTZ Watches|
Emergency Mission Watches|
MONTBRILLANT Watches|
NAVITIMER Watches|
SKYRACER Watches|
SUPER AVENGER Watches|
SUPEROCEAN CHRONOMATIC Watches|
SUPEROCEAN HERITAGE Watches|
SUPEROCEAN HERITAGE 46 Watches|
SUPEROCEAN HERITAGE CHRONOGRAPHE Watches|
3.
|replicat tiffany|
tiffany jewelry|
Replica Bags|
Hermes ...
sdf   |2010-01-27 10:05:20
christian louboutin
christian louboutin cheap
christian louboutin sale
christian louboutin discount
christian shoes
christian louboutin shoes
designer handbags
louis vuitton handbags
replica handbags
ugg classic tall
ugg classic short
ugg ultra tall boots
christian louboutin boots
MBT shoes discount
MBT shoes
ugg classic cardy boots
ugg boots
Tory Burch Shoes
Giuseppe Zanotti shoes
louboutin
ugg boot
Anonymous   |2010-01-15 01:54:25
dfsfsdf
Gucci   |2010-01-21 05:02:30
chanel bags for cheap



Gucci shoes cheap

chanel handbags for sale

Replica louis vuitton for cheap


chi on sale

GHD for cheaphandbag
handbags
handbags
bags
handbags
handbags
handbags
bags
handbags

bags
louis vuitton
louis vuitton
louis vuitton
louis vuitton
louis vuitton
handbag
louis vuitton
lv
louis vuitton handbags
lv
lv handbags
lv gift
lv handbags
gucci bags
lv   |2010-01-25 06:30:21
chanel handbags for cheap

gucci handbags for sale

Balenciaga bags

louis vuitton bag

louis vuitton handbag for cheap

ghd very cheap

ugg boots for cheap

china Wholesale
brand
luxury
luxury
luxury
luxury
luxury
luxury
ugg
uggg
ugg
ugg
chi
chi
chi
chi
chi
straightener
luxury
luxury
ghd
ghd
ghd
ghd
ghd
ghd
replica watches  - replica watches   |2010-01-07 11:02:55
replica watches,rolex watches,breitling watches,tag heuer,tag heuer carrera.
replica watches,rolex watches,breitling watches,tag heuer,tag heuer carrera. 09.01.07T
louis vuitton,louis vuitton,replica gucci,replica chanel.
louis vuitton,louis vuitton,replica gucci,replica chanel.09.01.07T
replica watches  - replica watches   |2010-01-07 11:02:28
louis vuitton,louis vuitton,replica gucci,replica chanel.
buy cheap replica watches,rolex watches,breitling watches,tag heuer,tag heuer carrera.
replica watches,rolex watches,breitling watches,tag heuer,tag heuer carrera.
ugg boots,ugg boots09.01.07T
ljzforever  - add a function   |2009-07-23 15:45:39
i am a Chinese so my english is pool
i suggest add a function
now use your plugin i can
$.include("a/b/c/d/e/f/a.js")
$.include("a/b/c/d/e/f/b.js")
$.include("a/b/c/d/e/f/c.js")

but a/b/c/d/e/f is so long
your can add a function, for example:
$.includePath = "a/b/c/d/e/f/";
so i can write
$.include("a.js")
$.include("b.js")
$.include("c.js ")

hehe~~

line 57:
$.each(urls,function(){$.include.load(this,onload,null);});
modify to
$.each(urls,function(){$.include.load($.includePath + this,onload,null);});
bin   |2009-07-28 08:08:31
why not use:
var p = "a/b/c/d/e/f/";
$.include(p+"a.js");
$.include(p+"b.js") ;
...
Sebastian  - re: add a function   |2009-12-18 10:47:59
bin wrote:
why not use:
var p = "a/b/c/d/e/f/";
$.include(p+"a.js");
$.include(p+"b.js") ;
...


Either so or Arash could at least implement this feature into the key/value interpretation. Then it could look like this:

Code:

$.include({
'includePath':'/a/b/c/d/e/f/',
'script1.js':function(){ /*something*/ },
'script2.js':function(){ /*something*/ },
 'somecss.css':null,
 'temp2.html':function(data){alert(data)}
},
globalCallback
);
Anonymous   |2009-07-03 09:59:56
Buy nike shoes and nike shox and puma shoes and nike dunks and nike shox and nike shoes and nike dunks and jordan shoes and cheap nike shoes and nike air force 1 from here !
Aaron Peters  - Preserve order and parallel downloading   |2009-04-28 16:30:42
Hi Arash,

this plugin is interesting.
I'm looking for a good way to:
a) load multiple JS files
b) in a specific order
c) in a non-blocking way (browser continues to render page/download other objects)
d) in all major browsers

Being able to do this with jQuery is a plus, since it is the main library on the site.

I'm gonna test this plugin sometime soon and will send you my findings/comments.

- Aaron
Blake  - continued...   |2009-03-10 14:45:43
and to load your files:

Code:
$.include(
[
{
'url':'script1.php',
'type':'js',
'callback':function (){ /*something*/ }
},
{
'url':'script2.php',
'type':'js',
'callback':function(){ /*something*/ }
},
{
'url':'somecss.php',
'type':'css',
'callback':function(){ /*something*/ }
}
]
,globalCallback
);


This change in code still keeps the original functionality of the code, but just adds the new way of including your files.

Hope someone finds this useful!
marklee  - great work   |2009-07-27 11:39:07
That's great,Thanks for the mention. The article itself shows that you put a great deal of care into your work credit cards

Thanks for sharing all these links and informative stuff.
Blake  - continued...   |2009-03-10 14:45:08
Code:
load: function(url,onload,callback,type){
var type = (type == null) ? false : type;
if(type == false){
if($.include.exist(url))
return onload(callback);
if(/.css$/.test(url))
$.include.loadCSS(url,onload,callba ck);
else if(/.js$/.test(url))
$.include.loadJS(url,onload,callback);
else
$.get(u rl,function(data){onload(callback,data)});
}else{
if($.include.exist(url))
  return onload(callback);
if(type == "css")
$.include.loadCSS(url,onload,callback);
else if(type == "js")
$.include.loadJS(url,onload,callback);
else
$.get(url,func tion(data){onload(callback,data)});
}
},
Blake  - thank you, and i have made an addition   |2009-03-10 14:42:21
Great script!

I wanted to load php files with javascript in them, but they are not parsed as javascript because they do not end with .js.

I know i could of made a simple .htaccess file to fix this, but for what i was working on, i wanted the php extension.

What i needed was a variable so i could specify the file type as "js" or "css".

This is what i came up with:

Code:
if(typeof urls=='object'){
if(typeof urls.length=='undefined'){
$.include.counter[luid] = 0;
for(var item in urls)
$.include.counter[luid]++;
return $.each(urls,function(url,callback){$.include.load(url,onload,callback);});
}els e{
$.include.counter[luid] = urls.length;
return $.each(urls,function(i,group){$.include.load(group['url'],onload,group['callback '],group['type']);});
}
}


Code:
load: function(url,onload,callback,type){
var type = (type == null) ? false : type;
if(type == false){
if($.include.exist(url))
return&n...
hitigon  - A bug in IE 8   |2009-08-01 12:07:47
Hello!
It's a useful plugin,thank you for your sharing first.
But,when I use this plugin testing in IE 8,there is a problem happened.
the "src" or "href" attribute is a string type but not the true value,it's "[object]"(alert(src === "[object]");),so I cant use it in my IE8(win2008 R1),then I change the code "js.setAttribute('src',url);" to be "js.src = url;",it works,so is loading CSS.I google this question but there is no answer,so please tell me about this bug,thank you!
Eric  - thank you!   |2009-03-09 03:35:53
Been looking for this functionality for months, but didn't want to roll my own. Works great!!
Anonymous   |2010-02-04 10:08:15
We have the 100% real louis vuitton handbags,you can click our webpage: Louis Vuitton to choose handbags for yourself. Sure,someone want Christian Louboutin,we know the Louboutin shoes are so fashion all around the world,it’s the best women’s shoes,if you are a fashion girl,you can buy discount handbags or manolo blahnik in my online shop.
Anonymous   |2010-02-04 10:11:32
We have the 100% real louis vuitton handbags,you can click our webpage: Louis Vuitton to choose handbags for yourself. Sure,someone want Christian Louboutin,we know the Louboutin shoes are so fashion all around the world,it’s the best women’s shoes,if you are a fashion girl,you can buy discount handbags or manolo blahnik in my online shop.
Louis Vuitton   |2010-02-24 10:40:37
Gucci
Louis Vuitton
Christian Louboutin


alexander mcqueen|chanel bags|Chloe handbags|salvatore shoes|australia boots|Chanel Handbags|Chloe Shoes|st laurent yves|christian boots|Cheap Louis Vuitton|Christian Louboutin boots|st yves laurent|Chloe Handbags|D&G|tory burch boots|Christian Louboutin boots|d&g bags|D&G Bags|tory burch flats|Christian Louboutin heels|discount handbags|Fashion online shop|tory burch shoes|Christian Louboutin high heels|GUCCI|Fendi boots|tory shoes|Christian louboutin shoes|Gucci Handbags|Fendi Shoes|ugg australia|christian shoes|handbags discount|Jimmy Choo boots|uggs australia|fendi|Miu Miu boots|womens short boots|giuseppe|louis vuitton backpack|Miu Miu Shoes|Yves Saint Laurent|Giuseppe Zanotti|Louis Vuitton Bags|Salvatore Ferragamo boots|Yves Saint Laurent shoes|Giuseppe Zanotti shoes|louis vuitton epi leather|Yves Saint Laurent boots|zanotti|Jimmy Choo|Louis Vuitton Handbags|Yves Saint Laurent Shoes|zanotti giuseppe|Jimmy Choo shoes|Louis Vuitton onlin...
louis vuitton   |2010-03-09 04:41:27
Chanel Handbags|Chanel|Gucci|Gucci Handbag|Christian Louboutin|Alexander McQueen|Chloe|Fendi|Giuseppe Zanotti|jimmy choo|Manolo Blahnik|Miu Miu|Salvatore Ferragamo|Tory Burch|UGG Australia|Yves Saint Laurent|LV|Louis Vuitton|Louis Vuitton Handbags|Louis Vuitton Bags|LV Surya Bags|LV Mahina Bags|LV Epi Leather Bags|LV Suhali leather Bags|LV Damier Canvas Bags|LV Nomade Leather Bags|LV Stephen Sprouse Bags|LV Evening Collection Bags|LV Monogram Canvas Bags|LV Monogram Denim Bags|LV Monogram Vernis Bags|LV Monogram Mini Lin Bags|LV Monogram Multicolore Bags|LV Show Fall Winter 2009 bags|LV Show Spring Summer 2009 Bags|Chanel Bags|Chanel 2009 Cluthes Bags|Chanel 2010 New handbags|Chanel 2009 Cambon Bags|Chanel 2009 Denim Bags|Gucci Bags|Gucci 2010 Classic bags|Gucci 2010 Cuise bags|Gucci 2010 Fall winter Bags|Chloe Bags|Marc Jacobs Bags|Prada Bags|Miu Miu Bags|Dior Bags|D& G Bags|Jimmy Choo Bags|Loewe Bags|Gucci|Handbags|Louis Vuitton Handbags|Chanel Handbags|Chloe Handbags|Gucci Handbags|

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated on Thursday, 03 December 2009 05:43
 
</terminal>