There is no standard way yet. There is a connection api but it still works only for some mobile browsers.
So it remains to load any volume object and take the load time, which you are already doing. But there are problems here - if you use small objects, then there will be a big error in measurements, if there are large, and the user has a bad Internet, you will wait for a long time for the result, and the user will have a lot of traffic. You can also load a lot of small images in parallel, counting the average speed and stopping when the measurement error is quite small.
But it all makes sense if you consider the speed of the user connection. If you measure it in order to give it relevant content (of higher or lower quality), it is better to measure it in fact, and switch according to the situation (for the user, the speed may change at any time).
GET
parameter, and so, your method is working as much as possible forjs
- ThisMan