javascript - Is it possible to chain jquery ajax requests as a one level queue (without nesting) -


the question arose idea dynamically load group of javascript files $.getscript.

i developing js-only front-ends of couple of projects, share libraries, , nice (or @ least seems) have 1 js file handles common libraries includes, , other 1 - handles specific libraries.

some of front-ends talking work widgets other websites, , until setup process of js file compression one, needed place widget single js include, , include dependencies in queue.

something like: $.getscript .getscript .getscript

so question has 2 parts: 1. make sense? 2. if yes, how?

thanks!

do mean following: want write

$.getscript("js/file1.js").getscript("js/file2.js").getscript("js/file3.js"); 

and result load 1 file server, contains specified (sort of file1.js + file2.js + file3.js), don't you? if it, seems impossible, @ least way. makes sense, one, because browser send 1 request instead of 3 (so performance better). implement want, need support server side. e.g. write

$.getscript("js/libraries?files=file1,file2,file3"); 

and server side should able parse request, append files mentioned in request, , send you. see, should exist on server side assist you;

if develop framework or such, can make predefined build, e.g. library contain

js/     file1.js     file2.js     file3.js common.js 

where common.js file1.js + file2.js + file3.js, , can automate it, change code, , run special build create common.js. way can rely on

$.getscript("common.js"); 

and that's better requesting

$.getscript("js/libraries?files=file1,file2,file3"); 

because in case of last 1 runtime job has performed (performance suffers bit). when develop our projects use jawr on server side make predefined bundles of javascript libraries/files


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -