1

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?

Community
  • 1
  • 1
Korijn
  • 1,383
  • 9
  • 27
  • If you can avoid the problem by detecting IE10 and IE11 you could look into *navigator.userAgent* which provides you with a user agent string. – Robin May 06 '15 at 10:06
  • I.e. browser detection? I can't assume that the code that I could write for that now will continue to work in a year or so. So it's not really an option for me. (Wasn't this already clear from my question?) – Korijn May 06 '15 at 10:38

1 Answers1

0

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>
Korijn
  • 1,383
  • 9
  • 27
  • Have you looked at [Google's Native Client](https://developer.chrome.com/native-client)? But that only works for Chrome. Silverlight only works for IE. What do you do for Firefox and Safari? Java works in most browsers for writing plugins, so that *could* be a cross-browser solution. But your users will have to allow the JRE to run in their browser process, something that is way more difficult than it should be (consider common IT policies). I solved this problem by running the DICOM parsing stuff at the server and using services to make a cleaner API, but not sure if this will help you. – Chris O May 26 '15 at 00:39