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

Batch rendering mode #203

Closed
kof opened this issue Apr 11, 2016 · 4 comments
Closed

Batch rendering mode #203

kof opened this issue Apr 11, 2016 · 4 comments
Labels
idea What if we turn JSS into styled-components?

Comments

@kof
Copy link
Member

kof commented Apr 11, 2016

As IE9 has a limit of 31 style sheets per document (style and link and @imports alltogether), we might want to implement an optional rendering strategy.

See Khan/aphrodite#45

An API that would be possible, inspired by apphrodite.

  1. Only one style sheet for all components.
  2. Styles are generated when .use is called.
import {create} from 'jss'

// Tell jss to render in batch mode.
const jss = create({batch: true})

const sheet = jss.createStyleSheet({
  button1: {
    color: 'red'
  },
  button2: {
    color: 'red'
  }
})
<div className={sheet.use('button1',  'button2')}></div>
@kof kof changed the title Batch rendering mode for IE9 Batch rendering mode Apr 14, 2016
@kof
Copy link
Member Author

kof commented Apr 15, 2016

Following assumptions need to be validated:

  • when we add a text node to an existing style sheet, does browser renders just added rules or there is an overhead of reparsing entire style sheet and recreation of the rules
  • when we use IE rendering using cssText, how much of overhead is it, the entire sheet needs to be def. reparsed
  • what is more efficient for IE .cssText or addRule api?
  • I have the feeling there is no guarantee that a style sheet is parsed by browser before react renders the dom node. If this is not guaranteed, there is a chance of repaint at the moment we insert styles when node is already rendered. This is can happen when batching lots of rules into one insert by using libs like asap.

@kof
Copy link
Member Author

kof commented May 15, 2016

Another possibility is a separate batch-renderer project + lazy option.

Batch renderer will ensure all rules a rendered in one sheet, "lazy" option will ensure that rules are not parsed until they are used.

@kof
Copy link
Member Author

kof commented Jun 23, 2016

When rendering only styles which are in use, the order of rules needs to be preserved by comparing the resulting rules with the original order.

@kof kof added the idea What if we turn JSS into styled-components? label Aug 21, 2016
@kof
Copy link
Member Author

kof commented Apr 11, 2017

Closing this because we never got any request to support IE9.

@kof kof closed this as completed Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea What if we turn JSS into styled-components?
Projects
None yet
Development

No branches or pull requests

1 participant