gmpassos/dom_builder

dart2js compile size concern

Closed this issue · 5 comments

Hello there!

I took this library for a spin. So far so good!

My only concern is that a tiny program can generate such a massive dart2js output with -O4:

import 'package:dom_builder/dom_builder_dart_html.dart';
void main() {
  parseHTML('<span>hello world</span>');
}

Compiled output size was at first around 520KB. Some time with https://dart-lang.github.io/dump-info-visualizer/ tool and realized that about half of the compiled size is with package:html. I did a PoC, where I replaced the package:html API with dart:html and could reduce the compiled size to 251KB.

I just would like to pick your mind a bit. Is compile size a concern to you or is this package considers other aspects more important? If so, what are those?

Thanks!

Nice catch! I didn't know that package:html was increasing significantly the dart.main.js. I will take a look in how to optimized that, or how to not depend on package:html.

Regards

One question:

  • What is your use case for dom_builder?

Regards.

Nice catch! I didn't know that package:html was increasing significantly the dart.main.js. I will take a look in how to optimized that, or how to not depend on package:html.

I can send you a gist with a patch file for my experiment. Yeah, html is pretty terrible in that regard. I suppose they take the approach of making things work the exact same way in js and on server side - the way they do it is by using their own parser instead of using one provided by browsers.

What is your use case for dom_builder?

Right now, nothing. I'm looking into 3rd party packages that I could use to implement "dual rendering". The exact same template could be used on client side and on server side. A way to approach SSR, I guess. If I can adjust the parser of that library to be closer to Angular's template syntax, that'd be nice too, would offer a migration path without having to throw away big chunks of carefully constructed component templates. DSX pointing in a rough direction I want to go.

Also: I really don't want to port angular_compiler to NNBD and AngularDart is dead.

You can fork the project and send me the link of your new branch.

Also, can you show an example of angular syntax that you want to parse?

v2.0.7:

  • Added DOMHtml, a portable HTML handler and parser.
    When compiling to the browser uses dart:html.