Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isLoaded feature #9

Open
wforney opened this issue May 9, 2011 · 4 comments
Open

isLoaded feature #9

wforney opened this issue May 9, 2011 · 4 comments

Comments

@wforney
Copy link

wforney commented May 9, 2011

When a script is loaded on the page via script tag and then jsdefer tries to include it jsdefer should test for it.

jsdefer should provide a boolean expression test configurable in the script definition via deferDef... The old Sys.loader had this feature and it allows conditionally including a script based on how you define it. There are lots of uses for this...

Load script B only if script A is there (assuming you're not using jsdefer exclusively for script loading (we can't totally enforce it in some of our scenarios).

@wforney
Copy link
Author

wforney commented May 20, 2011

Also ensure that jQuery version present on page is at least 1.5 due to failure of fail method otherwise.

@wforney
Copy link
Author

wforney commented Jun 10, 2011

deferDef has a loaded property on each definition that is an expression. This is a temporary way to use this for now:

jsDefer.deferDef({
jQuery: {
bare: true,
url: ASPNETCDN + "/jQuery/jquery-1.6.1.js",
urlMin: ASPNETCDN + "/jQuery/jquery-1.6.1.min.js",
loaded: !!window.jQuery
},

...

@wforney
Copy link
Author

wforney commented Dec 19, 2011

The workaround here is to make loaded a string like:

jsDefer.deferDef({
jQuery: {
bare: true,
url: ASPNETCDN + "/jQuery/jquery-1.6.1.js",
urlMin: ASPNETCDN + "/jQuery/jquery-1.6.1.min.js",
loaded: "!!window.jQuery"
},

This string then gets eval'd by jsdefer.

@wforney
Copy link
Author

wforney commented Dec 19, 2011

Also, there is a bug in jsdefer, the loaded gets set to false always, even if you specify it. Workaround is to put this in jsdefer in the defer function:

        var i, readyName, asyncLoad, result, prevPromise,
                runWait = 0,
                delayDomReady = options.delayDomReady || deferSettings.delayDomReady,
                min = options.min || deferSettings.min,
                scriptDef = getScriptDef(scriptName, basePath),
                url = scriptDef.url,
                loadUrl = (min && scriptDef.minUrl) || scriptDef.url,
                settings = jsDefer.extend(scriptDef, options),
                bare = settings.bare || scriptDef["bare"],
                contains = settings.contains || scriptDef["contains"],
                loaded = settings.loaded || scriptDef["loaded"],
                depends = settings.depends || scriptDef["depends"],
                multiple = settings.multiple || scriptDef["multiple"],
                parentPromise = scriptDef.prntPrms,
                promise = scriptDef.promise,
                runCb,
        //thisPromise,
                hasRun, hasRunPromise;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant