Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

5 HTML5 Features you need to know – Adnane Belmadiaf's Blog

$
0
0

Comments:"5 HTML5 Features you need to know – Adnane Belmadiaf's Blog"

URL:http://daker.me/2013/05/5-html5-features-you-need-to-know.html


HTML5 has been around for a while now, it introduces lots of new and exciting new JavaScript and HTML APIs for both mobile and desktop, so in this post you will discover some HTML5 features that will enhance your web apps and will save you a lot of time.

DNS Prefetching

DNS hostname resolution is one of the issues that can make any website slow. Modern browsers start to be very smart when it comes to DNS resolution, they try to resolve domain names then cache them before the user tries to follow any link on the webpage.

With the dns-prefetch feature you are allowed to manually control this operation by telling the browser which domain names to resolve :

<linkrel="dns-prefetch"href="//fonts.googleapis.com"><linkrel="dns-prefetch"href="//google-analytics.com"><linkrel="dns-prefetch"href="//www.google-analytics.com"><linkrel="dns-prefetch"href="//platform.twitter.com">

Link Prefetching

Link prefetching allows developers to specify pages or assets they want to silently preload once the page load, like loading the first search results :

<linkrel="prefetch"href="http://daker.me/2013/05/hello-world.html"/><linkrel="prefetch"href="http://daker.me/assets/images/avatar.png"/>

Also you can use the prerendering feature which will make your website even faster, the browser will fetch and render the entire next page on the background and show it only when the user click on the link :

<linkrel="prerender"href="http://daker.me/2013/05/hello-world.html"/>

Download Attribute

The HTML5 download attribute allows developers to force a file to download rather than go to that specific page, you no longer need to rely on server side code to do that :

<ahref="download_pdf.php?id=15"download="myfile.pdf">Download PDF</a>

Regular Expressions

I know you'll fall in love with this feature, no more js or a server side code to check if the user's input is a valid email or url adress, with the pattern attribute you can use regular expressions directly :

<inputtype="email"pattern="[^ @]*@[^ @]*"value="">

Datalist Element

Datalist element is a litle big addition, no more use of jQuery plugins for autocomplete inputs combined with a server side code that hit the database on each user keystroke :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<formaction="form.php"method="post"><inputlist="cars"name="cars"><datalistid="cars"><optionvalue="Volvo"><optionvalue="BMW"><optionvalue="Bugatti"><optionvalue="Cadillac"><optionvalue="Chevrolet"><optionvalue="Chrysler"></datalist><inputtype="submit"/></form>

I hope this will help you save time and enhance you coding skills, let me know your thoughts in the comments below.


Viewing all articles
Browse latest Browse all 9433

Trending Articles