All pastes #2051699 Raw Edit

Untitled

public text v1 · immutable
#2051699 ·published 2011-04-28 20:44 UTC
rendered paste body
As i see it, this use case is fairly common. not niche at all. lets put some realworld names on this thing.

a.js: jquery-1.5.2.js
b.js: somecaoursel_or_slider.jquery.js
c.js: lightbox.jquery.js

b.js depends only on a.js
c.js depends only on a.js

i have multiple pages, most using lightbox and slider/carousel on same page. this is the scenario the example proceeds with.

on each of these pages, it is different elements that needs to be activated with the slider and lightbox, in addition, there are callbacks for various events of the sliders/lightbox(IE user cclicks on carousel, or views a lightbox, for whatever reason). The callbacks are also different on a pr-page basis

features of a.js are framework, all my javascript depends on it.

I extend a.js with b.js and c.js to give additional features

b.js and c.js adds unique and separate features. these all have equal importance on my pages.
b.js and c.js are upstream features, meaning, they are found on CDNs and all sorts of stuff, thousands are using them.

my choices as of now are these:

1:
load a.js, block until done
load b.js, c.js, block until done, execute my code that initiates b.js and c.js features.

this way, they will both be activated simultaneously, however, this also means that one of the features will inevitably be waiting for the other.

2:
load a.js, block until done
load b.js, block until done, load my initiate code
load c.js, block and load initiate code.

i have manually decided which feature is most important, and which will be loaded and run first.
----

I could also combine my initiate code with the b.js and c.js directly, but that would lead to multiple copies for each page, and as far as i see, only downsides compared to 1 and 2.


so my proposal is alterations so that i can add a callback for each script that is executed, and a method of specifying equal priority scripts.

As to how much realworld performance is gained, i cannot say, however, this is a scenario that hits nearly all jquery/mootools etc using sites, also, the fact that as of now, things are not really done in a way that screams "unoptimal", which to me is very unappealing