Hacker News new | ask | show | jobs
by bawolff 815 days ago
Even without early hints, i assume you could do the same thing with the link http header.

Or if you really dont care about performance, just loading the start (e.g. <head>) of the document and wait a little bit to see which subresources are loaded.

2 comments

Yep that also works, I've made a proof of concept for that ages ago https://github.com/Mechazawa/pixelAntiAdblock/blob/master/ap...
Yeah but the critical piece here is loading Early Hints happens before the HTML is sent to the browser. So the server can change the HTML of the page based on what the browser does. (I wonder about the performance impact of this though.)

Trying to detect adblock via a <link> (or an <img> or a <script> etc) means you have to do the check in javascript, which can be manipulated by the browser.

No, not neccesarily.

With the link http header (different from the <link> tag) you just send the http headers, but can still change the response body based on what the browser does.

Alternatively, By sending just the start of the document, then pausing, you can change the rest of the document based on what the browser does with the start, since browsers start loading css/js referenced in the document before the main document completes loading. (Before web sockets were a thing, this was basically the technique used for that sort of thing, called "long polling")

None of this requires javascript.

You can send some content (<link>) and then wait for something else to happen (prefetch) before you continue sending the rest of the content (the page).