Coder Social home page Coder Social logo

jquintozamora / polyfill-io-feature-detection Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 2.0 38 KB

Feature detection in the browser before loading polyfill using services like polyfill.io

License: MIT License

JavaScript 98.51% HTML 1.49%
polyfill polyfill-service feature-detection

polyfill-io-feature-detection's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

polyfill-io-feature-detection's Issues

Intl locales can't be loaded

Hi. I'm trying to use this package for loading Intl polyfill. For correct work, it needs also Intl.~locale.[locale] to be loaded. But if I try to add any locale to features I get the next message:

Feature Intl.~locale.en-US can not be detected because it has not JavaScript API.

What if instead of skipping features with ~ this tool will include them in the query string for polyfill.io if the root feature (like Intl for Intl.~locale.en-US) is not supported by the browser?

es6 syntax in Index.js

Hi,

You have a 'let' keyword in index.js. So when using uglify, there is an exception.
Could you modify it to var?

Antony

Add support for IE7 & IE8

For the sake of supporting polyfill.io fully, you may want to support IE7 & IE8 in the code base. Two things are needed :

  • Not using unsupported features in the codebase itself
  • More robust loadScript

Features

Features impacted (as I could tell):

  • Array.prototype.filter
  • Array.prototype.map
  • String.prototype.lastIndexOf
    All of these features are provided by polyfill.io, for IE7 & IE8

Solutions:

  • Inline polyfill each of these (just like contains)
  • try-catch approach, loading all features if detectBrowserUnsupportedFeatures couldn't even run

loadScript

Proposed version that supports old IE:

function loadScript(src, done) {
    var finished = false

    function handleLoad () {
      if (!finished) {
        finished = true
        done(src)
      }
    }
  
    function handleReadyStateChange () {
      if (!finished) {
        if (script.readyState === 'complete') {
          handleLoad()
        }
      }
    }
  
    function handleError () {
      if (!finished) {
        finished = true
        done(new Error('Failed to load script ' + src))
      }
    }
    var script = document.createElement('script')
    script.onload = handleLoad
    script.type = 'text/javascript'
    script.onreadystatechange = handleReadyStateChange
    script.onerror = handleError
    script.src = src
    document.head.appendChild(script)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.