You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Order is destroyed when merging across multiple pages #16
minimalcss will generate minimal CSS payloads for multiple URLs. It then combines them into one final merged version. Suppose you have two URLs with different DOM nodes present.
I'm still wondering if it'd be possible to technically solve this. Probably not. But perhaps there's an opportunity to see what values of selectors change when the second URL comes in. Hard.
If it is possible to log each css rule line number and filename, than you can merge them according to line number in css file
page 1 Line number 100 .btn { font-size: 10px } Line number 200 .btn-default { font-size: 12px }
page 2 Line number 100 .btn { font-size: 10px }
Result after merge:
Line number 100 .btn { font-size: 10px } Line number 100 .btn { font-size: 10px } Line number 200 .btn-default { font-size: 12px }
thinking about it a bit more, i think a partial solution might be to get the minimal css per file, then merge all same files before merging others. csso(csso(base1_minimal, base2_minimal), csso(specific.css)). still relies on file ordering though.
@ihorsl I think it goes deeper than that. It might work'ish. Suppose it's possible to write something like that it might get it right 90% of the time, but those 10% would be a disaster. I say disaster because the work to untangle it would be really hard. You'd almost have to start over from scratch.
Remember, something like this minimalcss is probably only needed when you use a CSS framework. If you handcoded all the CSS it'd probably so minimal (no pun intended) that none of this tooling is necessary.
My point is, we got to be careful so we don't really need to understand what we're optimizing. Otherwise the abstraction will leak.
Activity
peterbe commentedon Feb 5, 2018
Added a blurb about it in the README.
I'm still wondering if it'd be possible to technically solve this. Probably not. But perhaps there's an opportunity to see what values of selectors change when the second URL comes in. Hard.
ihorsl commentedon May 29, 2019
If it is possible to log each css rule line number and filename, than you can merge them according to line number in css file
page 1
Line number 100 .btn { font-size: 10px }
Line number 200 .btn-default { font-size: 12px }
page 2
Line number 100 .btn { font-size: 10px }
Result after merge:
Line number 100 .btn { font-size: 10px }
Line number 100 .btn { font-size: 10px }
Line number 200 .btn-default { font-size: 12px }
leeoniya commentedon May 29, 2019
you may find this useful: leeoniya/dropcss#22
leeoniya commentedon May 29, 2019
thinking about it a bit more, i think a partial solution might be to get the minimal css per file, then merge all same files before merging others.
csso(csso(base1_minimal, base2_minimal), csso(specific.css)). still relies on file ordering though.EDIT: nope, this prolly won't work either :(
peterbe commentedon May 30, 2019
@ihorsl I think it goes deeper than that. It might work'ish. Suppose it's possible to write something like that it might get it right 90% of the time, but those 10% would be a disaster. I say disaster because the work to untangle it would be really hard. You'd almost have to start over from scratch.
Remember, something like this
minimalcssis probably only needed when you use a CSS framework. If you handcoded all the CSS it'd probably so minimal (no pun intended) that none of this tooling is necessary.My point is, we got to be careful so we don't really need to understand what we're optimizing. Otherwise the abstraction will leak.