How does Feed.ly determine iFrame load progress?

2019-04-09 20:51发布

问题:

If you read RSS items on Feed.ly, you have an option to "preview" the item, which opens up the corresponding URL in an iFrame. They have somehow gotten a load bar on top of the frame though, can't figure out how they got access to the load percentage.

If they're faking it, they're doing a fantastic job. Anyone have any idea how to get load progress from an iframe?

回答1:

If you couldn't get an actual bytesLoaded and bytesTotal, you could track how long it takes all users to load that iframe and come up with an average loading speed that you then use to govern the progress bar. If you wanted it to be even more accurate, you could track how the current user's loading speeds match up to the average loading speeds on every item they preview (or maybe per feed) and develop an even better approximation based on that user's relative times.

The first few people would just be guesswork but after that, you might be able to get relatively close. Naturally, that approach is going to work better when you have a large number of users, like feedly does. For a smaller site or more niche RSS feeds, it would be less useful.

Edit: I don't think they're actually doing that though. At least, I don't see them making any tracking requests. I think they're probably just faking it. After previewing a lot of items, sometimes the bar is only half way full when it disappears and sometimes it fills in completely before you see more than a white screen. I think it's a placebo.