A place to cache linked articles (think custom and personal wayback machine)
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 4 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. title: Graded browser support
  2. url: https://github.com/springernature/frontend-playbook/blob/master/practices/graded-browser-support.md
  3. hash_url: 85aca7f1c273ca304c3e546a24334f33
  4. # Graded browser support
  5. * [Our criteria for browser support](#our-criteria-for-browser-support)
  6. * [How we implement graded browser support](#how-we-implement-graded-browser-support)
  7. ## Our criteria for browser support
  8. We follow the guidelines for graded browser support outlined by Nate Koechley at Yahoo:
  9. [Yahoo Grade Browser Support guide](https://github.com/yui/yui3/wiki/Graded-Browser-Support)
  10. Our browser support in summary:
  11. - Grade-A are browser versions that are explicitly *supported*. A product bug in one of these browsers is a high priority.
  12. - Grade-C are browser versions that are explicitly *_not_ supported*. We serve only the minimum styling and functionality to these browsers.
  13. - Grade-X are the grey area between Grade-A and Grade-C. We serve them the same code as Grade-A, but we do not test our products against these browser versions. Over time, analysis of errors and usage patterns may cause some browsers in Grade-X to be deliberately demoted to Grade-C.
  14. | Tables | Grade-A support | Grade-C support |
  15. | --------------------------- |:-------------------------------:| ------------------:|
  16. | Chrome | latest stable, latest stable -1 | < 29 |
  17. | Edge | latest stable, latest stable -1 | n/a |
  18. | Firefox | latest stable, latest stable -1 | < 29 |
  19. | IE | 11 | < 11 |
  20. | Opera | latest stable | < 16 |
  21. | Safari iOS | latest stable, latest stable -1 | < 7 |
  22. | Safari MacOS | latest stable, latest stable -1 | < 6.1 |
  23. | Android browser (Chromium) | Latest stable | < 4.4 |
  24. ### Notes
  25. - We have no explicit Grade-C support for Edge.
  26. - We have no Grade-X support for IE, as we officially only support IE11, with anything below that being Grade-C. However, due to browser technical limitations we can only detect IE10+, so IE10 is, for now, included in our CTM media query.
  27. ## How we implement graded browser support
  28. Our primary approach to graded browser support is the "cutting the mustard" progressive enhancement technique, based upon the principles developed by the BBC: [Cutting the Mustard](http://responsivenews.co.uk/post/18948466399/cutting-the-mustard). However, user agent sniffing is still applied on some legacy projects.
  29. We load a basic stylesheet to all users. This contains only [normalisation](https://necolas.github.io/normalize.css/) and a few small enhancements to the user-agent stylesheet.
  30. To load the full experience only in modern browsers (grade-A and grade-X) we implement logic in the media attribute of the `<link>` element that identifies the main stylesheet, loading the stylesheet only in browsers that recognise the properties of that media query.
  31. This technique is documented here: [Cutting the Mustard with Media queries](https://www.sitepoint.com/cutting-the-mustard-with-css-media-queries/).
  32. The media queries we use are based upon [CSS Only Mustard Cut](https://github.com/Fall-Back/CSS-Mustard-Cut), with a preference towards combining them into one rather than separating them out into multiple `<link>` elements. Note that you **cannot** add line breaks to the media query if they are combined.
  33. Note: As mentioned above, while our graded browser support table specifies Internet Explorer 10 and below as Grade-C, until an updated media query is found this approach will render IE10 as Grade-A.
  34. ```html
  35. <link rel="stylesheet" href="your-css.css" media="only screen and (-webkit-min-device-pixel-ratio:0) and (min-color-index:0), (-ms-high-contrast: none), only all and (min--moz-device-pixel-ratio:0) and (min-resolution: 3e1dpcm)">
  36. ```
  37. We couple the loading of JavaScript to the loading of the enhanced CSS.
  38. If the browser loads the CSS within the media query, then load the JavaScript.
  39. In order to check this, we use [window.matchMedia](https://developer.mozilla.org/en/docs/Web/API/Window/matchMedia).
  40. ```javascript
  41. (function() {
  42. var linkEl = document.querySelector('link');
  43. if (window.matchMedia && window.matchMedia(linkEl.media).matches) {
  44. var script = document.createElement('script');
  45. script.src = 'your-script.js';
  46. script.async = true;
  47. document.body.appendChild(script);
  48. }
  49. })();
  50. ```
  51. The javascript code outlined above will fail in Internet Explorer if there is more than one link element. You can get around this by targeting the specific link element using a class or ID.