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
dart2js generates code that references all DOM element types, even if Dart code doesn't use those types #11263
Comments
One potential solution to this issue is to let the developer explicitly state which DOM types to pull into the dart2js output. If the developer can give dart2js more information (e.g. "I only expect to use DivElement"), then perhaps dart2js can generate code without all of the mentions to SVG, WebGL, etc. The developer could use a metadata annotation on the import for dart:html to provide a list of DOM types the application requires. |
cc @kasperl. |
This would work with an HTML5 parser. Then the user could just tell dart2js which HTML files she plans to use. |
Issue #9556 has some cleanup work. Once the cleanup is done, the empty elements like the following will vanish: $$.CircleElement = {"": "StyledElement;"}; All that will be left is the SVGCircleElement tag on the defineNativeMethods call for the superclass. Best case scenario: all that is left of the SVG library is a list of ~70 SVG element tags, a little over 1k of string which will compress to a few hundred bytes. If the above reduction is working but the list of tags is too big, we can probably reduce it. In summary, lets see if we can make the general case work before complicating the programming model. cc @karlklose. |
Added this to the Later milestone. |
Removed this from the Later milestone. |
The empty classes are removed by r25067 Added Fixed label. |
Thanks for the update! |
This code:
main() {
query('#hello').text = 'Howdy!';
}
Generates JavaScript code that contains references to many (all?) of the DOM element types (such as SVG, WebGL, etc). The user code doesn't require or use SVG or WebGL classes, and shouldn't have to pay the tax.
This is especially important if a developer wishes to create a custom element with Dart and use that custom element on a page that has various other custom elements written in JavaScript. Ideally, the Dart custom element would be reasonable in size.
The text was updated successfully, but these errors were encountered: