7 ms·
More HTML5 APIs
- sergiotapia 14y agoI really look forward to the media and prefetching API's. They seem really needed, and now that I've read about them, I wish I could use them in production.
- eli 14y agoWell, you can rel="prefetch" it just won't do anything unless you're using Firefox (AFAIK).
- riffraff 14y agoyou can also use "prerender"[0] which will work in chrome but has a slightly different behaviour https://developers.google.com/chrome/whitepapers/prerender https://developers.google.com/chrome/whitepapers/prerender
- emmelaich 14y agoIs there a privacy vulnerability with prefetching? I can imagine timing it and making inferences about whether it's been cached and therefore previously visited.
- evan_ 14y agoI don't see how you would be able to tell how long it takes to load- unless you control the site it's prefetching, in which case you should be able to tell if they've been there before anyway.
- eli 14y agoPossibly true, but I'm pretty sure you can already do that with something like <img onload="someJavascript()">
- scottfr 14y agoI opened up the developer console on Chrome and copied in his code to make the whole page full-screened. It doesn't seem to do anything and doesn't show an error message. Is there an issue with the code? I know Chrome supports the full-screen API.
- pyrotechnick 14y agohttp://html5please.com http://html5please.com
- pygy_ 14y agoFrom an advertiser'a point of view, the visibility API is a boon. For users not so much. I've recently noticed several sites that pause their video ads when the tab is hidden. I don't look at adds. I have several ad jingles/slogans from my youth wired in my brain. They popon cue, and since I don't want to add new ones to my collection, I now actively avoid ads. This means that I now have to look elsewhere while the video is playing, or hide the screen, and it annoys me to no end. /rant. To browser authors: This feature has some use, but a huge potential for user abuse. It would be most helpful if it were possible disable the API, or to enable it selectively on a site by site basis.
- TazeTSchnitzel 14y agoYou know that they might just be detecting onfocus/onblur instead, right? They aren't necessarily using the Page Visiblity API.
- pygy_ 14y agoBad memory. Now that you tell it I actually reverse engineered a page (script compiled with GWT, strings mangled, most of the script being one or two letter variables, often the same ones), to find out how they were doing it, and in that case, they were using document or window.onblur. I tried to overwrite the event handlers without success.
- eli 14y agoI think I'm missing something. Wouldn't the alternative be to keep playing the video ad even when you're not looking at it? Why is that better? I don't want my browser wasting cycles to render a video it knows I can't see. At the risk of stating the obvious, it sounds like you have a problem with ads, not a problem with the visibility API.
- pygy_ 14y agoMeanwhile you can do useful/less annoying stuff in other tabs. And I have a problem with ads that are forced on me, true, my case may be extreme, but I'm sure that it annoys other people too.
- andrethegiant 14y agoCould someone explain to me a use case for the battery API? I can't think of a single situation where it would be beneficial. The article states that you can detect if a user's battery is low to avoid battery-intensive processes, but do you think developers are going to spend their time inflating their scripts to deliver a poorer web experience to their users just because they have a low battery?
- quarterto 14y agoSave prompts when the battery is low?
- Zigurd 14y agoQuick poll: Which is worse... a) Battery-aware HTML5 apps b) Having a save command
- quarterto 14y agoOk, what about more frequent autosaves?
- tadfisher 14y agoWouldn't those drain the battery?
- Zigurd 14y agoAndroid's APIs enable easy implementation of a sqlite-based data model, where changes are always persisted. That doesn't solve the problem for things like CAD that need an in-memory object-oriented data model, but the Android support for observer patterns can be wrapped around any data model, and the ability to quickly, which means, in practice, incrementally, persist changes is driven by both Android-specific issues like needing to respond to lifecycle events quickly, and by general mobile considerations like a battery that could fail unexpectedly. In other words, you need to solve the "don't explicitly save" problem for reasons ranging from "it's more robust" to "it fits Android UI conventions" anyway.
- MatthewPhillips 14y agoI hope they start to provide, when appropriate, non-JavaScript APIs for some of these things. Full screen is one that could be useful.
- emddudley 14y agoNon-JavaScript? Like what?
- flebron 14y agoSay, <a href="foo" fullscreen="true">, I'd guess.
- MatthewPhillips 14y agoProbably something new would have to be invented as there is no mechanism to send messages to the browser in plain html. Something equivalent of a form element but without the action attribute. It would be nice to have something like (spitballing) <some-new-form> <input type="hidden" value="fullscreen" /> <input type="submit" value="Go fullscreen" /> </some-new-form>
- detst 14y ago> Probably something new would have to be invented as there is no mechanism to send messages to the browser in plain html. Web components. At least their usage is plain HTML and could do what you want internally with the JS API.
- cbrandolino_ 14y agoOh please no, we barely got rid of the target attribute /:
- abraham 14y agoMost browsers have keyboard shortcuts to go to full screen already.
- achal 14y ago:( No love for the Audio API? http://www.w3.org/TR/webaudio/ http://www.w3.org/TR/webaudio/ (Admittedly, it's only supported in Webkit at the time)
- kevingadd 14y agoThat is pretty much why, I'd expect. Though Mozilla apparently have plans to integrate it in Firefox, at which point you could probably start using it in HTML5 apps in the wild!
- monsterix 14y agoGood that this came in just when I was playing with the Fullscreen API. It is the Firefox's implementation of this that's bothering me. Figured out that we have to put up with a hack to avoid the default "background:black" that Firefox applies to the element being pulled to full_screen mode. But what is worse is that Firefox kills y-scrolling completely for pages longer than screen-height. In effect one can't have full_page rendering (like on iPad or in normal state of browsers) of the website in full_screen mode of Firefox. That's seriously crippling. How do we tackle this? Is there any enlightened soul who got this done already? Or I am hitting the wall, right now?
- kevin_p 14y agoSounds pretty stupid, but it sounds like you should be able to get round it by sticking everything in a scrollable wrapper div (height:100%; overflow:scroll) when fullscreen mode gets activated. Or just do things the old fashioned way and tell the user to hit F11 (or apple-shift-F on mac) to put their browser into manual full-screen mode, which supports scrolling.
- monsterix 14y agoI did try this. I don't remember this exactly, but what was happening then is that only the visible part of the page came in to the F11 wrapper div. There no-scroll in the full-screen browser window. In effect you're left with an option to introduce scrolls within content divs, and that looked worse. Chrome on the other hand manages this quite nicely.
- Arceliapfa 14y agoNice! I like the link prefetchin
- tonywok 14y agoYeah, definitely going to try that out my next mobile app. Great article.
- true_religion 14y agoHowever, I think its only supported on Mozilla Firefox. I used to support it on my media sites when Mozilla was topdog, but since the share is split between Chrome/IE I no longer do so.
- deleted 14y ago[deleted]
- dbaupp 14y agoDoes it hurt to support it? As in, why did you stop supporting it if the infrastructure was already there?
- true_religion 14y agoOh its not that. When I re-wrote the pages, or upgraded services, I just stopped including/thinking about prefetching for Firefox. So it pretty rapidly disappeared from all the sites that I support/operate.
- quarterto 14y agoGoogle uses it if the first link is "very probable to be the desired hit". [0] Minor nitpick: prefetching is not an API. Still cool, though. [0]: http://en.wikipedia.org/wiki/Link_prefetching http://en.wikipedia.org/wiki/Link_prefetching
- OlavHN 14y agoPeerConnection is an API now enabled in vanilla Chrome. http://www.webrtc.org/blog/seeyouontheweb http://www.webrtc.org/blog/seeyouontheweb
- FuzzyDunlop 14y agoI've been writing a library that abstracts the getUserMedia API, and I've found it really interesting to be able to use JS and HTML to interact with hardware in a (mostly) simple way. Even though I prefer the native implementation of these things, the pure creativity HTML and JS allows (because it's less difficult) is where these features really shine. Calling WebRTC "skype in a browser" is just the tip of the iceberg.
- discordance 14y agoFor the curious: Fullscreen API works on Safari, Firefox and Chrome. Page Visibility works on Chrome and Firefox. getUserMedia (camera access) works on Chrome Canary and Opera Tested on latest public releases; Safari 6.02, Chrome 23.0.1271.64 and Firefox 16.0.2
- bzbarsky 14y agogetUserMedia (alas, prefixed) should also work in Firefox, generally speaking... Though maybe it's preffed off by default? The patch for it landed for Firefox 15: https://bugzilla.mozilla.org/show_bug.cgi?id=752353 https://bugzilla.mozilla.org/show_bug.cgi?id=752353
- taitems 14y agoInteresting fact learnt from the Phonegap creator at Web Directions: calls to the battery API actually decrease battery life.