Giter VIP home page Giter VIP logo

html5please-api's Introduction

HTML5 Please API

Introduction

Developers wishing to use modern browser features in their applications or demos often run into a very common issue: a user somewhere may be using a browser incompatible with what your project needs to function correctly. There are instances where this behaviour can be normalized using polyfills, but for all other instances, it's necessary to display a notification or message informing the user they need to upgrade to a different browser. The HTML5 Please API can help with this.

Rather than needing to take care of browser detection and manually listing the latest versions of browsers supported each time you use a modern feature, we provide a solution for this. Our API uses data sourced from caniuse and retrieves browser support information based on features you require on the client-side. For example, if you want your page to only render on browsers that support Transitions and Canvas, you can send in an API request to api.html5please.com and print the returned HTML as a message when the page is viewed on browsers that do not support these features.

We also provide a number of useful snippets to save you time creating a notification for your users. The project can generate widgets using a special Modernizr plugin, pure JavaScript snippets that do the same or simply HTML links for those that wish to link their users out to a page with suggestions on browsers to consider upgrading to in order to support all the features needed for your site.

Reference

Most users will be able to configure a snippet for their needs using our main widget/snippet builder. If however you would like to learn more about the options supported by the API, please see below for more details.

API URIs

URI Format:

http://api.html5please.com/[feature1+feature2..+featureN].[format]?[option1&option2..optionN]

URI Example:

http://api.html5please.com/video+audio+webgl.json?callback=h5please&texticon&html

For more information on formats supported, see the 'Formats' section below.

Features

We support the majority of HTML5 features and probably cover any feature you're looking for. Please feel free to look at the keywords.json to find out what features are supported. Alternatively you can use the autocomplete on the site to do so.

Formats

Data from the API is output either as a JSON object, XML or HTML (depending on the format you choose). For complete details on our data objects, see the wiki.

  • html: the output will be valid HTML with the mimetype of text/html.

  • json: the output will be valid JSON with the mimetype of text/json.

  • xml: the output will be valid XML with the mimetype of text/xml.

Options

  • nocss: the HTML will not include the stylesheet.

  • text: the HTML will be optimized for text output.

  • icon: the HTML will be optimized for icon output.

  • supported: the JSON will only output whether the agent supports the requested features.

  • noagent: the JS will return results for all browsers with no agent detection.

  • callback = [ functionName ]: the output will be JavaScript, wrapped in this function name.

UA Detection

The HTML5 Please service uses UA detection as a part of our process for detecting the browser currently used by the user. This is strictly used for deciding what browsers and browser versions we should recommend end-users upgrade to in order to use a feature. For more information on this, please see this entry on the wiki.

Examples

We will be posting more demos and examples of the how the project can be used shortly. In the mean time if you would like to look at a project already making use of the API, see http://mothereffinganimatedgif.com/.

History

Divya has a post about the project history we recommend checking out. This project began as one of her LazyWeb requests for a healthy choose-your-browser page. @addyosmani worked on the initial implementation, to be later replaced with a much more rich API and UI by @jonathantneal, @nimbupani and other contributors. Jon's service is what currently powers much of the HTML5 Please API. We are still very much working on improving it and recommend looking at the 'Contributing' section below in case you would like to help out.

Contributing

We welcome any and all contributions to improve the project. Please feel free to fork and send through a pull request if there's something you feel we could be doing better.

Note that the site that represents this project runs off index.html and references files from site folder. It uses SASS so please make any changes to style.scss rather than style.css. The logic for much of the UI is based in site/js/script.js should any changes need to be made on that front.

Credits

  • @fyrd for amazing caniuse API which underlies this work
  • @jonathantneal for all the magic with PHP and building a robust API on top of caniuse's data
  • @aaronlayton for initial design of html output
  • @drublic for various fixes to the builder/UI
  • @addyosmani for help with the docs
  • @divya & @paul_irish for corralling the project together

html5please-api's People

Contributors

aaronlayton avatar addyosmani avatar arthurvr avatar drublic avatar fyrd avatar jeromeetienne avatar jonathantneal avatar mathiasbynens avatar micha149 avatar paulirish avatar rowno avatar sindresorhus avatar tagawa avatar

Stargazers

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

Watchers

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

html5please-api's Issues

docs: clarify how we recommend browsers

we put a lot of logic into how we recommend browsers

  • no IE recommendation if you're on mobile or mac/linux
  • no mobile browsers if you're on desktop
  • it's conditional on what your current browser is (somehow..)

I think these are all very useful. we should document them on the homepage so people understand the value of the service

Option to show needed features in widget

I really like this API. I was looking if something like this existed, and I am very glad it does.
However, I would like to show the user a small list of the features that the site they visit needs and their browser doesn't support, since I think it is good to keep visitors informed of the reasoning behind needing to switch browser to use the site.

What I propose is something like:

"This page uses the following features:
-WebGL
-WebAudioAPI
that are unavailable in your current browser. Please view this page in one of the following browsers:"

I would like this to be added as an optional way to present the message, with an option to turn it on in the API.

API doesn't send through full HTML?

Seems this API doesn't work as intended, or has changed at some point.

Looking at http://api.html5please.com/ I've entered some HTML5 features to check for (I'm not using Modernizer), if I just enter the provided code into a test page then it doesn't actually display a list of browsers or logos as I was expecting it to.

I checked the html property on the object sent to the callback function, and other than a couple of <div> elements it was empty.

I then checked the provided link http://mothereffinganimatedgif.com/ to see what I was doing wrong (as that site is given as an example site) but I guess I wasn't doing anything wrong, because if I go to that site using Safari then you'll notice it doesn't work there either! See the following screen grab...

...notice it doesn't show any browsers listed, or any logos - nothing like the "In Action" section of the page http://api.html5please.com/ suggests it should.

Seems something has gone wrong or been updated and not checked.

Can someone advise if I'm doing something really stupid or if indeed there are issues with the API.

Thanks.

Missing: Read More content

(it's late so sorry if I've missed something in the index)

It appears that the content for Read More hasn't been fleshed out yet. Testing Chrome/Canary nothing happens when I click on 'read more' at the moment.

I'm assuming it's yet to be done, but figured an open issue might remind everyone :)

Add an option to install Chrome Frame for oldIE

Could you make an option to the html5please call to offer Chrome Frame as an option?
For people who are working on bringing HTML5 to "internal" or "enterprise" apps, read IE678, they know their target audience and they know that they most likely do not have admin rights. This leaves Chrome Frame as the only option.

test pages

i think its time to make some test pages. using the JSON and mashing it against handlebars

or the HTML and tossing it into a jquery ui dialog

whatever we expect people to do with this service

that way we'll have demos to show and make sure our JSON data is ideal

Lets find a few HTML5 demos, apps that we can envision things for: http://www.dropmocks.com/ and chrome.angrybirds.com and .. mothereffinghsl.com

Problem with the generated widget

The generated widget code uses plus signs for separating features instead of spaces. Example:

features: "localstorage+filereader+draganddrop+svg"

Modernizr.html5please cannot split this using spaces:

opts.features.split(' '); (line 23 of modernizr.html5please.js)

Also, on line 46 of modernizr.html5please.js, parenthesis are missing which causes a wrong value for the url variable.

Even with these two issues fixed, my h5p-message shows undefined. (a.html is undefined.)

SSL support

there's that.

punting this issue for as long as possible. :)

Tweak html output

"upgrade" is a bit strong especially for unstable features. We should say "use".

All information about browsers should be presented without hover, because this is essential info that shouldn't be hidden.

script async is invalid without src

"Here is your widget" uses the async attribute on script without src.

"The defer and async attributes must not be specified if the src attribute is not present." says the spec. (It has no effect on inline scripts.)

HTTPS Mixed Content

The current beta version of Firefox [23] blocks mixed content when accessing a site through HTTPS. Requests made from a secure website to the API are considered to be mixed active content and are blocked by default. Any chance HTTPS will be available in the future?

Multi-language API

Hi everybody!!!

The API is great, but as 90% of my users are spanish, it would be perfect if you could set the language of the html response into the request options (I don´t know if this is the right way to do it, or I should create my own html code from the json response).

If you need some help with the translation, just let me know. ok?

Regards,

David.

Server-side Caching

Was talking to @addyosmani that we would need some sort of server-side caching. A simple hash of the requested UA & request options might be sufficient?

Anyone knows enough PHP to pick this up :)

Design to dos

  • Adjust space when there are no options (e.g. XML format)
  • Autocomplete drop-down is fugly. Needs fixing.
  • Builders section needs more tweaks.
  • Test it in all mobile devices.
  • Show the 'more info'
  • Move html to be first option in format
  • Make text&icon option to be default as button option.

Clientside Caching

Need to set correct response headers so that content is cached client side. This will ensure repeated requests to the html button wont incur more bandwidth.

Caching could also be turned on for the json / xml output aswell as the data wont be updated often

Request: Show fewer browsers

We are showing a lot of browsers that support certain features. However, most users are on a particular browser, and if a latest version of that browser supports the requested feature, only return that value. If there is no support for that feature among any version of the browser, return the list of other browsers that support that feature.

Option for desktop browsers only

The API lists iOS Safari among the suggested browsers. This doesn't look right to me, if the goal is to give the user links to browsers they can upgrade to.

There should be an option to limit results to desktop browsers only.

add example of usage.

like

if (supportsStuff)
  initApp()
else
  makeAPIJSONPcall()

add after builder section.

Callback "html" is invalid

"html": "­<style>....... </style><div class="caniuse">...."

This is invalid HTML. Why the ­? Since the next thing is a block box, it doesn't do anything anyway.

It should be more like:

"html": "<div class="caniuse"><style scoped>....... </style>...."

Hosting plans

We're working with alexis behind caniuse to host this at api.caniuse.com but we've also discussed api.html5please.com and others.

If you have the resources to host an webservice like this chime in.

On setting src on a script element

The "Here is your widget" boilerplate that uses Modernizr has this:

var ref = document.getElementsByTagName('script')[0]; var url = 'http://api.html5please.com/' + features.join('+') + '.json?callback=Modernizr.html5please.cb' + opts.options ? ('&' + opts.options) : ''; script.src = url; ref.parentNode.insertBefore(script, ref); return false; };

Does this even work? Scripts are generally marked as "already executed" and then don't want to execute again. Or what if the first script element is a data block (i.e. has a type="" attribute that causes the script to not be executed)? Also, "what if two scripts did this?" (http://blogs.msdn.com/b/oldnewthing/archive/2005/06/07/426294.aspx ).

Why not just create a new script element?

Do we need a congratulations message?

I think ideally the html should show nothing if the browser supports the features required. The intent is to get out of the way of users when not necessary. The prompt and html should only render if the features are not supported.

docs page feedback

  • can we use <dt><dd> combo for the API details?
  • let's group options by HTML and JSON output. clarify that callback if your homeboy
  • styling? should we style with caniuse's general flavor?
  • add some In the Wild examples (which we don't have yet)
  • btw i added a bunch of text to explain wtf this is. also some :target: styling

Designer Proof

I'm not really sure how to use the HTML version since it's just a link. But @nimbupani said that information is still missing. Anyways.. maybe that's the plan or maybe it's too late, but would it be a good idea to make it like how Twitter buttons are used? Basically a wizard with a couple options that spits out a code snippet for people to paste onto their sites:

<div id="caniuse" data-support="audio+css-transitions" data-appearance="nocss+icon+text"></div>
<script> some code </script>

Then designers don't have to deal with JSON callback stuff. ;-)

The Windows XP problem

Should the API even show Internet Explorer as an option to visitors that are using Windows XP with features that require IE9+?

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.