Skip to content

docs: clarify performance concerns around props and restProps #9047

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

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

benmccann
Copy link
Member

I wonder if there's also something here around whether innerHTML can be used to optimize HTML creation? @dummdidumm may know...

@changeset-bot
Copy link

changeset-bot bot commented Jul 26, 2023

⚠️ No Changeset found

Latest commit: da685f5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dummdidumm
Copy link
Member

What do you mean by that?

@benmccann
Copy link
Member Author

I just tested a bit in the REPL

<picture>
    <source srcset={avif} type="image/avif">
    <source srcset={webp} type="image/webp">
    <img src={img.src} width={img.w} height={img.h} alt="Example">
</picture>

gets converted to

picture = element("picture");
picture.innerHTML = `<source srcset="${avif}" type="image/avif"/> <source srcset="${webp}" type="image/webp"/> <img src="${img.src}" width="${img.w}" height="${img.h}" alt="Example"/>`;

while

<picture>
    <source srcset={avif} type="image/avif">
    <source srcset={webp} type="image/webp">
    <img src={img.src} width={img.w} height={img.h} {...$$restProps} alt="Example">
</picture>

gets converted to

			picture = element("picture");
			source0 = element("source");
			t0 = space();
			source1 = element("source");
			t1 = space();
			img_1 = element("img");
			if (!srcset_url_equal(source0, source0_srcset_value = avif)) attr(source0, "srcset", source0_srcset_value);
			attr(source0, "type", "image/avif");
			if (!srcset_url_equal(source1, source1_srcset_value = webp)) attr(source1, "srcset", source1_srcset_value);
			attr(source1, "type", "image/webp");
			set_attributes(img_1, img_data);

I guess that's not really related to the usage of $$restProps specifically though, so probably shouldn't be mentioned here.

@dummdidumm
Copy link
Member

Yeah unrelated, also I think we can't optimize this because we don't know if the props which are set are all settable as attributes, some may only be settable through the Dom property.

@dummdidumm dummdidumm merged commit d6abd0a into master Jul 27, 2023
@benmccann benmccann deleted the props-docs branch August 22, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants