Is there a way to know anything about hardware resources of 'platform' accessing webpage?

前端 未结 2 561
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 03:41

I\'d like to be able to find out about a browser\'s hardware resources from a web page, or at least a rough estimation.

Even when you detect the presence of modern t

2条回答
  •  情书的邮戳
    2021-01-02 04:25

    In general, the available (to web pages) information about the user's system is very limited.

    I remember a discussion of adding one such API to the web platform (navigator.hardwareConcurrency - the number of available cores), where the opponents of the feature explained the reasons against it, in particular:

    • The number of cores available to your app depends on other workload, not just on the available hardware. It's not constant, and the user might not be willing to let your app use all (or whatever fixed portion you choose) of the available hardware resources;
    • Helps "fingerprinting" the client.
    • Too oriented on the specifics of today. The web is designed to work on many devices, some of which do not even exist today.

    These arguments work as well for other APIs for querying the specific hardware resources. What specifically would you like to check to see if the user's system can afford running a "fancy 3D animation"?

    As a user I'd rather you didn't use additional resources (such as fancy 3D animation) if it's not necessary for the core function of your site/app. It's sad really that I have to buy a new laptop every few years just to be able to continue with my current workflow without running very slowly due to lack of HW resources.

    That said, here's what you can do:

    • Provide a fallback link for the users who are having trouble with the "full" version of the site.
      • If this is important enough to you, you could first run short benchmarks to check the performance and fall back to the less resource-hungry version of the site if you suspect that a system is short on resources.
    • You could target the specific high-end platforms by checking the OS, screen size, etc.
      • This article mentions this method on mobile: http://blog.scottlogic.com/2014/12/12/html5-android-optimisation.html
    • WebGL provides some information about the renderer via webgl.getParameter(). See this page for example: http://analyticalgraphicsinc.github.io/webglreport/

提交回复
热议问题