Dojo по сравнению с Dijit - файлы, чтобы включать или сослаться?

Примерно:

-(void)someFunction
{
  NSLog([self toBinary:input]);
}

-(NSString *)toBinary:(NSInteger)input
{
  if (input == 1 || input == 0) {
    return [NSString stringWithFormat:@"%d", input];
  }
  else {
    return [NSString stringWithFormat:@"%@%d", [self toBinary:input / 2], input % 2];
  }
}
6
задан Cœur 21 September 2017 в 14:49
поделиться

3 ответа

You have a few options actually:

  1. You could use the CDN for everything (though using the full source locally does give you better error messages). Google has them as well. Dijit is here: http://ajax.googleapis.com/ajax/libs/dojo/1.3.2/dijit/dijit.js FYI. This has many advantages in my opinion. User caching of the JS being the primary one.

  2. Build a layered file. I think the O'Reilly book has a section about it but the PragProg book is better in this regard IMO. There's also this doc on dojocampus.org about building. This will trim down the files you need to upload to GAE and speed up your app loading. This is actually what I do in order to cut down on HTTP requests.

  3. Keep doing what you are doing. :)

Regarding the errors you are seeing about 404 for en-us files are essentially harmless. Here's a better description.

You also might be reloading dijit files by using dijit.uncompressed.js and dijit-all.js and causing problems in the process...but I'm not sure about this one.

8
ответ дан 10 December 2019 в 00:41
поделиться

I just want to clarify that when using CDN all you need to include is the main Dojo script. The rest will be pulled in automatically when you dojo.require() them.

If for some (technical) reasons you don't want to use the X-Domain loader (CDNs use this type of loader), you can do a custom build (well-described in many places). After the build you copy only relevant files to your server. No need to copy all 2000+ tests, demos, unused DojoX projects, Dijits and so on.

During the build you will create a single minified file (or a few layers), which will include all Dojo JavaScript code you use. If you use Dojo widgets, their templates will be already inlined, so you do not incur hits for them. As part of the build CSS files are combined together and minified too. So literally in most cases you will have just two files: a Dojo layer, which includes everything + your custom code, and a CSS file. In more complex cases you may have more files, but usually we are talking about handful.

How to make sure that everything is in the build? Fire up your favorite network analyzer (Live HTTP Headers, Firebug, Fiddler2, or Charles Proxy would do fine) and see if you hit any files outside of your build. If you do — include them in the build, or try to figure out why they are requested, and eliminate these requests (some localization-related calls are fine).

Personally I would start with the CDN option — works well, no hassle, hosted by somebody else with fat pipes.

2
ответ дан 10 December 2019 в 00:41
поделиться

To address your first question, use the full source version locally for development, so that you can get clearer debug info which points to a legible line in source, rather than the single line the minified version is reduced to. Use the CDN for production.

0
ответ дан 10 December 2019 в 00:41
поделиться
Другие вопросы по тегам:

Похожие вопросы: