Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Tags: maragudk/gomponents

Tags

v1.2.0

Toggle v1.2.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Reduce number of allocations for rendering elements and attributes (#265

)

This change does some optimizations to reduce the number of memory heap
allocations.

Also:
- Checks for `io.StringWriter` and uses that if available.
- Pre-allocates byte slices for commonly used strings.
- Fixed the benchmarks to not count `strings.Builder` allocations.

These are the benchmark results from before the changes (with the
benchmark fix):

```
go test -bench . -benchmem ./...
goos: darwin
goarch: arm64
pkg: maragu.dev/gomponents
cpu: Apple M3 Max
BenchmarkAttr/boolean_attributes-16         	25371446	        46.81 ns/op	      40 B/op	       3 allocs/op
BenchmarkAttr/name-value_attributes-16      	13534495	        88.24 ns/op	      72 B/op	       4 allocs/op
BenchmarkEl/normal_elements-16              	14068998	        86.28 ns/op	      48 B/op	       5 allocs/op
PASS
ok  	maragu.dev/gomponents	4.894s
PASS
ok  	maragu.dev/gomponents/components	0.163s
goos: darwin
goarch: arm64
pkg: maragu.dev/gomponents/html
cpu: Apple M3 Max
BenchmarkLargeHTMLDocument-16    	     526	   2092062 ns/op	 2950444 B/op	   90031 allocs/op
PASS
ok  	maragu.dev/gomponents/html	1.463s
PASS
ok  	maragu.dev/gomponents/http	0.168s
?   	maragu.dev/gomponents/internal/assert	[no test files]
PASS
ok  	maragu.dev/gomponents/internal/import	0.135s
```

After:

```
go test -bench . -benchmem ./...
goos: darwin
goarch: arm64
pkg: maragu.dev/gomponents
cpu: Apple M3 Max
BenchmarkAttr/boolean_attributes-16         	51947022	        19.75 ns/op	       8 B/op	       1 allocs/op
BenchmarkAttr/name-value_attributes-16      	18138727	        64.87 ns/op	      24 B/op	       2 allocs/op
BenchmarkEl/normal_elements-16              	21048692	        55.48 ns/op	      24 B/op	       2 allocs/op
PASS
ok  	maragu.dev/gomponents	3.687s
PASS
ok  	maragu.dev/gomponents/components	0.158s
goos: darwin
goarch: arm64
pkg: maragu.dev/gomponents/html
cpu: Apple M3 Max
BenchmarkLargeHTMLDocument-16    	     714	   1535017 ns/op	 2630426 B/op	   40028 allocs/op
PASS
ok  	maragu.dev/gomponents/html	1.398s
PASS
ok  	maragu.dev/gomponents/http	0.171s
?   	maragu.dev/gomponents/internal/assert	[no test files]
PASS
ok  	maragu.dev/gomponents/internal/import	0.137s
```

v1.1.0

Toggle v1.1.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Benchmark large document and run in CI (#246)

Fixes #229

v1.0.0

Toggle v1.0.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release v1 (#226)

v1.0.0-beta1 gave no problems with my other gomponents libraries, that
of others, and some of my large projects, so releasing v1!

No more breaking changes! 😁

v1.0.0-beta1

Toggle v1.0.0-beta1's commit message

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Remove mention of SVG package in doc comments

v0.22.0

Toggle v0.22.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Remove SVG package (#214)

Because the added value of having this was very small, and I don't want
to confuse people about what's properly supported, I've removed the SVG
package. As #196 showed, there can easily be conflicts between HTML and
SVG, and the rendering isn't really set up for anything else than HTML.

It's still easy to create SVG elements: `html.SVG` exists in this repo,
and the rest is often just a string that can be included using `g.Raw`.

Fixes #206

v0.21.0

Toggle v0.21.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Use go workspace in example app (#211)

v0.20.5

Toggle v0.20.5's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Make Groups renderable (#181)

This change makes the result of `Group` renderable directly, instead of
panicking, with the important caveat that root-level attributes are
_ignored_. I don't think this will give problems in practice, as the
main use case for rendering `Group` is basically to return root-level
elements to the client using something like HTMX.

I tried adding a `Fragment`, but it was weird and confusing having two
functions (`Group` and `Fragment`) do essentially the same thing, the
only difference being whether the argument was a slice of `Node`s or
varargs.

Fixes #162

v0.20.4

Toggle v0.20.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Add links to godoc (#183)

Also add an example for `http.Adapt`.

Fixes #182

v0.20.3

Toggle v0.20.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Add LabelAttr and List attributes (#175)

Fixes #168 and fixes #169.

v0.20.2

Toggle v0.20.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix wrong codecov (#166)

We don't need coverage for the example code and internal testing
helpers.