6

Does anyone knows ajax script loader that allows lazy loading of js and css files and also consist of dependency list that can be defined in external script?

Naor
  • 23,465
  • 48
  • 152
  • 268
  • What do you mean with "lazy loading of js ?" ? – genesis Jun 05 '11 at 11:15
  • @genesis: I'm guessing he means only to load a JS file if it's required, for example a set of thumbnails may be loaded and then require "fancybox" support, then the relevant JS/CSS/images can be loaded as required. – Marcel Jun 05 '11 at 11:22
  • aha. Su just add it into  in ajax loaded page. or not? – genesis Jun 05 '11 at 11:23
  • @genesis: Marcel explanation is exactly what I ment. I can't just add it to the – Naor Jun 05 '11 at 11:43

4 Answers4

4

Why not use http://unwrongest.com/projects/lazy/ ?

  • Noar: I think yes because it's aimed to jquery – genesis Jun 05 '11 at 11:48
  • Its a jQuery Plugin so you have to use jQuery. Well but i dont understand your question completely, what do you mean with good for jquery users? –  Jun 05 '11 at 11:52
  • @Daniel Ruf: What I asked is does this package fits only if I use jquery? Can I use this package without jquery? – Naor Jun 05 '11 at 12:09
  • you have to use the javascript framework jquery because its a jquery plugin –  Jun 05 '11 at 12:23
1

In my various projects I use LABjs. Easy and flexible :)

sitifensys
  • 2,024
  • 16
  • 29
1

If you need a smart why to load or skip resources, see http://yepnopejs.com/ :

yepnope is an asynchronous conditional resource loader that's super-fast, and allows you to load only the scripts that your users need.

Modrnizr is a good example of yepnoejs usage.

Udi
  • 29,222
  • 9
  • 96
  • 129
  • Can I define dependencies list in yepnoejs? – Naor Jun 05 '11 at 11:56
  • @Naor: I do not see any smart built in dependency features in yepnopejs. However: 1: `On top of all that, inside of your array, each item can be a test object, another array, or a string literal...`, so you can create a master object with your requirements. 2. You can use the callbacks and the complete event, look for `What happens if I use yepnope inside of a yepnope callback?`. 3: You can probably further load stuff from within loaded scripts, although this is not optimal in many ways. – Udi Jun 05 '11 at 12:44
1

Just include

<script src="your_lazy.js"></script>

in script (html) which is loaded with your ajax-called page

genesis
  • 50,477
  • 20
  • 96
  • 125