3 ms·
> The algorithm isn't that expensive. It's quadratic in length of the paragraph, no? Not a problem for most reasonable text chunks, but browsers have to deal
by bzbarsky 16y ago
> The algorithm isn't that expensive.
It's quadratic in length of the paragraph, no? Not a problem for most reasonable text chunks, but browsers have to deal with unreasonable text too. In particular, O(N^2) algorithms in browser layout are generally unacceptable...
- rakingleaves 16y agoBut it would only apply when the web page author "opted in" with the appropriate CSS, no? Doesn't seem like it should affect performance on pages that don't use the feature.
- bzbarsky 16y agoIf you made it an opt-in, that might be doable... though there would still be the danger of pages cargo-culting into the opt-in. But at that point you're also asking browsers to maintain two separate line-wrapping codepaths, of which one is not used anywhere to a first approximation. Browser vendors seem to be somewhat resistant to doing that sort of thing.
- glhaynes 16y agoIt could maybe be switched off (even if requested) once a paragraph hits a certain threshold size. Of course I suppose that could get complicated as the paragraph gets mutated by JavaScript... you don't want to be turning it on and off all the time.