travco / postcss-extend

A PostCSS plugin to minimize the number of repeat-selectors and rules you write
MIT License
114 stars 8 forks source link

Performance #18

Closed stephenway closed 8 years ago

stephenway commented 8 years ago

Not sure if this is related to just the nature of extends or how this plugin was designed, but I recently ran a speedtest with postcss-devtools on my compile and postcss-extend was reported at running 3.79 seconds. Maybe there is a way to speed this up? Thoughts?

Screenshot of my stack: screen shot 2016-01-28 at 2 46 31 pm

travco commented 8 years ago

Sadly it's part of how @extends have to be handled, because it's capable of extending in an anti-pattern, it has to check the full CSS doc for the selectors it's extending. Implemented perfectly, for n-many @extends to evaluate and x-many selectors: x * n things to process. It is not implemented perfectly, but I feel I got reasonably close with a recursive solution (still not pretty).

If it's becoming an issue, I can suggest utilizing @define-placeholder more as it's stricter, can't be used out of pattern, and doesn't cause a recursive check for more extensions as you can't extend out of those rules.

stephenway commented 8 years ago

@travco Thanks for the detailed response! I have been checking out how @define-placeholder works and really like that solution. I might eventually switch to using that. Thanks

travco commented 8 years ago

No problem, Happy to hear that keeping @define-placeholder in the plugin might help someone, Sorry to hear you found the inevitable N^2 curve, Hoping to get some time in the near future to go back through and root out the cause of the "blank output" issues #17