gmpassos / dom_builder

Helpers to generate DOM elements or HTML
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

dart2js compile size concern #1

Closed daniel-v closed 3 years ago

daniel-v commented 3 years ago

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!

gmpassos commented 3 years ago

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

gmpassos commented 3 years ago

One question:

Regards.

daniel-v commented 3 years ago

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.

gmpassos commented 3 years ago

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?

gmpassos commented 3 years ago

v2.0.7: