Search code examples
javascriptgoogle-chromesilverlightcross-browsernpapi

How to properly deal with Silverlight deprecation?


Recently, Chrome deprecated NPAPI support, so that means no Silverlight. Now, I've learned to be a good web developer and prefer feature detection over browser detection to deliver a good user experience. Unfortunately, it seems impossible to do NPAPI support feature detection properly.

I've built a JavaScript replacement for our Silverlight tool. I initially check if the user is on IE9 or older using conditional comments, which is a reliable approach (correct me if I'm wrong). In that case, I'd serve them Silverlight tool. Other browsers are assumed to support all the necessary features (we only target Desktop browsers in this case), so they are served the new JS tool.

After testing, it turns out that IE10 and IE11 are too slow to handle our application well. Specifically some I/O operations (MD5 hashing and DICOM parsing) are approx. 10-15x slower. I thought I'd then just serve ALL versions of IE the Silverlight tool, but conditional comments are no longer supported in IE10+.

I'm torn. It seems like I have to resort to unreliable browser detection after all. My only alternative appears to be testing if the JS engine is slow but that doesn't seem reliable either. So I turn to the good people of StackOverflow; what to do?


Solution

  • It's a shame no one had a better suggestion. In the end I was able to write a pure JavaScript replacement for our Silverlight control. Since IE10 and IE11 still had poor performance for the I/O operations, I decided to detect them to fall back to the Silverlight control.

    <!--[if IE]>
        <script type="text/javascript">
            window.is_ie = true;
        </script>
    <![endif]-->
    <script type="text/javascript">
        function isIE(ua) {
            if (ua.indexOf('MSIE ') > -1)
                return true;
    
            if (ua.indexOf('Trident/') > -1)
                return true;
    
            return false;
        }
        if(!window.is_ie) {
            window.is_ie = isIE(window.navigator.userAgent);
        }
    </script>