Skip to content

Implement HTM without an intermediate representation - #59

Closed
jviide wants to merge 12 commits into
developit:masterfrom
jviide:htmini
Closed

jviide wants to merge 12 commits into
developit:masterfrom
jviide:htmini

Conversation

@jviide

@jviide jviide commented Jan 9, 2019 •

Copy link
Copy Markdown
Collaborator

This pull request suggests an alternative approach to #48 and #53. Instead of building an intermediate representation (a function in #48 and a list of instructions in #53) h is used to evaluate the end result directly during template parsing.

This version supports stricter content security policies (like #53) and multiple root elements. The compressed code size is pretty small:

Build "htm" to dist:
        452 B: htm.mjs.gz
        399 B: htm.mjs.br
        517 B: htm.umd.js.gz
        455 B: htm.umd.js.br

The major con of this approach is the lack of caching, which makes the "usage" benchmark much slower compared to the other PRs. Running the benchmarks from the perf-test-harness branch gives the following numbers:

  Creation Usage
#48 17,395/s 664,807/s
#53 (no-eval) 78,365/s 444,821/s
this PR 121,157/s 131,251/s

@jviide

jviide commented Jan 9, 2019

Copy link
Copy Markdown
Collaborator Author

The "usage" test in perf.test.mjs fails, as the benchmark result is smaller than 100 000.

@znk

znk commented Jan 10, 2019

Copy link
Copy Markdown

um sir stop being that perfect

@jviide

jviide commented Jan 16, 2019 •

Copy link
Copy Markdown
Collaborator Author

After the latest updates the code sizes are:

Build "htm" to dist:
        434 B: htm.mjs.gz
        392 B: htm.mjs.br
        498 B: htm.umd.js.gz
        447 B: htm.umd.js.br

And the perf-test-harness benchmarks (seems that there's a small speed-up):

  performance
    ✅  creation
       Creation: 150,905/s, average: 6µs
    ✅  usage
       Usage: 164,445/s, average: 6µs

@jviide

jviide commented Jan 21, 2019

Copy link
Copy Markdown
Collaborator Author

The latest changes by @developit take the sizes down once more:

Build "htm" to dist:
        425 B: htm.mjs.gz
        379 B: htm.mjs.br
        494 B: htm.umd.js.gz
        441 B: htm.umd.js.br

@jviide

jviide commented Feb 20, 2019

Copy link
Copy Markdown
Collaborator Author

Closing this in favor of #62, which essentially includes the features of this PR as well as #53.

@jviide jviide closed this Feb 20, 2019
@jviide jviide mentioned this pull request Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants