3 ms·
Sorry for my ignorance, but does that amount to loading a library on demand? If so, yes, Dart can do this: import 'package:deferred/hello.dart' deferred as h
by markdog12 10y ago
Sorry for my ignorance, but does that amount to loading a library on demand? If so, yes, Dart can do this:
import 'package:deferred/hello.dart' deferred as hello;
// When you need the library, invoke loadLibrary() using the library’s identifier.
greet() async {
await hello.loadLibrary();
hello.printGreeting();
}
- Touche 10y agoThat does indeed work. I just tried it, and it works beautifully. The only problem is that the main output js file is still 107kb, quite large.
- markdog12 10y agoWhen I test this out, I get a 94KB file. That's reasonable depending on what you're doing.
- wstrange 10y agoAlso worth pointing out that Dart can do tree shaking at compile time, to eliminate library code that is never called