So, I am creating a JavaScript widget set (jQuery), and I want to make sure that all elements of these widgets use box-sizing: border-box (and yes, I know, this means that I can only support IE version 8 or higher, I'm fine with).
Now I heard what to do [selector] > * very slowly, but how slow is it?
I mean only for one of the widgets, I have this selector to make sure that all elements have the right window size:
.jg-grid-wrap, .jg-grid-content-outer-wrap, .jg-grid-colum-actions a, .jg-grid-content-wrap, .jg-grid-wrap .hide, .jg-grid-wrap ul, .jg-grid-wrap ul li, .jg-grid-header-wrap, .jg-grid-header-wrap li, .jg-grid-header-wrap .sort-indicator, .jg-grid-row, .jg-grid-row li, .jg-grid-footer-wrap, .jg-grid-footer-wrap .column-selection .jg-grid-wrap .controls, .jg-grid-wrap .controls .first-page-link, .jg-grid-wrap .controls .previous-page-link, .jg-grid-wrap .controls .next-page-link, .jg-grid-wrap .controls .last-page-link, .jg-grid-wrap .controls .column-selection-link, .jg-grid-wrap .controls .set-page-link, .jg-grid-wrap .controls .total-page-count, .jg-grid-wrap .controls .record-counts, .jg-grid-wrap .controls .record-display-text { box-sizing: border-box; }
but it would be much smaller and easier to just write:
.jg-grid-wrap * { box-sizing: border-box; }
Also, if I add an element, now I must remember to add this to the huge selector, where with the star, I should not worry about it.
Do I really need to specify each individual element separately because [selector] > * really slow?
UPDATE
In the end, I'm just going to go with:
[class^=jg-] * { box-sizing: border-box; }
This selector has ~ 14% of a total of 4 ms based on Google Chrome. Others are slightly smaller (~ 4%), but thinking about this, CSS will be the last place that I probably need to worry about performance (my javascript code and server code will be the main part of the bottleneck). If I really need to optimize my chrome CSS profiler, there when I need it.