Closed wingman-jr-addon closed 3 years ago
So I've been mulling this over and there might be a less-hard-but-still-helpful improvement here. I think a key observation is that in most cases, the actual fetch from the network is relatively fast, but the scanning is slow. This means that relaxing it so that 1) the full string is still buffered and 2) simply ensuring that up to the replacement is able to be pushed out are acceptable relaxations to still see a big win.
While this is partially complete, I may leave it open as the input-side is NOT yet streaming and there may be a bit more there for squeezing performance out of the system.
I did a bit of characterization around this and found that - at least for my network connection - individual load events tended to be speedy enough that adding streaming in here would likely not be worth the complexity. Closing for now until a clear use case pops back up.
Rob--W from Mozilla brought up a good point on my http-response example makeover for the WebExtension examples over here. He noted that while buffer-then-replace was easy, it wasn't good from a user experience perspective. I agree; particularly with the new WASM backend debacle the loading of the first page of Google Images is terrible now and I think it would directly benefit from a streaming regex library.