Skip to content
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

(Optionally) Use a singleton style tag to inject styles #6

Closed
zgotsch opened this issue Oct 20, 2015 · 5 comments
Closed

(Optionally) Use a singleton style tag to inject styles #6

zgotsch opened this issue Oct 20, 2015 · 5 comments

Comments

@zgotsch
Copy link
Contributor

zgotsch commented Oct 20, 2015

IE9 will only use the first 31 <style> tags (https://support.microsoft.com/en-us/kb/262161). Since AFAICT Aphrodite creates a <style> tag for each class, it won't work on IE9 with a lot of components.

I don't know what the perf implications of this are, but I know that webpack's style-loader (https://github.com/webpack/style-loader) has an option for whether to use a single style tag or to use multiple.

@xymostech
Copy link
Contributor

Woah. Didn't know that 31 tag limit was a thing! We could probably make an option to append to an existing <style> tag instead of making a new one each time.

@zgotsch
Copy link
Contributor Author

zgotsch commented Oct 20, 2015

Yeah, you can probably just create one with an id the first time and then getElementById subsequent injections.

@jlfwong
Copy link
Collaborator

jlfwong commented Oct 21, 2015

Thanks for the bug report! Glad we got this now and not in production :)

It sounds like webpack does many style tag insertions by default, but detects when its in <= IE9, and then switches automatically to appending to a single style tag. Shouldn't be too hard to implement.

It would probably be good to land #1 too to help with this problem too.

@xymostech
Copy link
Contributor

I looked into the perf implications of this, it looks like using more style tags is faster than appending to a style tag each time, but not appending to a style tag all the time is way better. I'm gonna look into this now.

@xymostech
Copy link
Contributor

Oops, forgot to link to the jsperf: http://jsperf.com/append-to-style-vs-create-new-style

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

No branches or pull requests

3 participants