Code Splitting in Dart -


is there way to kind of code splitting in dart? i'd defer loading of used code accelerate initial code download. in javascript, i'd inject new <script> tag, in gwt i'd call gwt.runasync(). there similar in dart?

according this link, <script> injection won't work ("each html page can have @ 1 dart script tag", "we not support dynamically injecting tag loads dart code."). found this fixed issue claiming: "the initial 1 [use case] deferred loading, avoid massive downloads when code needed later, or perhaps needed in situations. have mechanism this.". unfortunately, couldn't find on how implement this. know this?

update sep 2014: this has been fixed!

dart supports deferred loading special import... deferred syntax. example:

import analytics.dart deferred analytics void main(){     analytics.loadlibrary.then((_) { // future         // code ready         enableanalyticscontrol()     }); } 

here an official tutorial using deferred loading.


i'm afraid you're trying still not possible (assuming you're not using dart2js is) .

see this issue.

as kasper said in comment 3, far has been discussed deployment feature dart2dart. vms involvement in supporting ends giving dart2dart generated code access loading sources lazily through library call. library api still needs specified though.

if are using dart2js can done. here blog post on how this.

const lazy = const deferredlibrary('reverser', uri: './part.js'); 

which let call lazy.load().then((_) { ...


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -