cujojs / curl

curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
https://github.com/cujojs/curl/wiki
Other
1.89k stars 216 forks source link

auto-start "main" module #238

Closed szepeviktor closed 10 years ago

szepeviktor commented 10 years ago

Is it OK to use curl's 'preloads' for starting my app?

var curl = {"baseUrl":"http:\/\/www.atlantisct.tk\/wp-content\/themes\/act",
"paths":{"jquery":"http:\/\/www.atlantisct.tk\/wp-includes\/js\/jquery\/jquery.js",
"jquery-migrate":"http:\/\/www.atlantisct.tk\/wp-includes\/js\/jquery\/jquery-migrate.min.js","mapster":"js\/jquery.imagemapster2.js",
"masonry":"js\/masonry2.js","kenburns":"js\/jquery.pixelentity.kenburnsSlider.min.js",
"ytapi":"\/\/www.youtube.com\/iframe_api?","main":"js\/main.js"},
"preloads":["main"]};

And please tell me what is the official way in the main module to "autostart"? do not look at it: http://www.atlantisct.tk/wp-content/themes/act/js/main.js

unscriptable commented 10 years ago

curl.js should load and evaluate main automatically when included in the config. You should not have to use preloads.

FWIW, you should not include the ".js" on "main" since curl assumes it's a module. "main":"js/main".

Hmmm... i see that main.js defines a named module, named "main". This doesn't match what's in the config: "js/main". Can you use an anonymous define() in main.js? Or name it "js/main"?

szepeviktor commented 10 years ago

Thank you! I moved js/ paths to baseUrl, and removed .js-s.

How to name minified scripts? 'script.min' does not load.

unscriptable commented 10 years ago

You must map a path to a named module if name!=path.

paths.main="script.min"

unscriptable commented 10 years ago

I guess you could have done that (mapped a path) rather than move main.js. :)

szepeviktor commented 10 years ago

I mean I've appended /js to baseURL

unscriptable commented 10 years ago

Ah ok. I see. Try mapping a path to the minified script and let m know if that works. :)

szepeviktor commented 10 years ago

:) Oh I realized that the path main: 'main' makes no sense. but main: 'main.min' works!!