{"id":4024,"date":"2017-02-09T06:38:03","date_gmt":"2017-02-09T11:38:03","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=4024"},"modified":"2024-02-20T17:42:11","modified_gmt":"2024-02-20T14:42:11","slug":"data-uris-web-design-project","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/data-uris-web-design-project\/","title":{"rendered":"Data URIs And How to Use Them in Your Web Design Project"},"content":{"rendered":"\n
You are probably reading this information on data URIs in HTML because you have some concerns about improving the performance of your website in any way that you can. Why not, it is one of the factors the likes of Google use to determine page rank.<\/p>\n\n\n\n
The good news is that using data URIs is one way to improve the speed of your website if used properly. This guide will show you how and when to use this HTML feature.<\/p>\n\n\n\n
You generally want to use them to enhance your website’s performance by reducing the number of HTTP requests made to your server. For a web page to display it has to load an array of resources including images, external CSS files, external JavaScript<\/a> files, fonts, and of course the HTML<\/a> source.<\/p>\n\n\n\n Depending on the design of your website these resources may start to take their toll and slow down a website’s load time significantly. One major reason why this happens is that of the several requests made to the server to pick up these resources.<\/p>\n\n\n\n Reducing the number of requests, therefore, shaves off a couple of milliseconds if not seconds from the load time. Using data from URIs can play a big part in this process.<\/p>\n\n\n\n There are generally three places you can use them. That is directly in the HTML, as a background image in your CSS<\/a>, and finally in your JavaScript code.<\/p>\n\n\n\n Before you are able to use these URIs you need to know what the official format looks like. The format of data URIs consists of the scheme, the optional media type, the optional base64 extension or character-set, and the data as seen below:<\/p>\n\n\n\n data:[<mime type>][;base64][;charset=<charset>],<encoded data><\/strong><\/p>\n\n\n\n To illustrate the above here is an example of the code. It is an image of this arrow:<\/p>\n\n\n\n These URIs are ideal for use when the files are not too large such as is the case with images. There is a trade-off in that when your image is small enough to warrant removing it from the queue of HTTP requests.<\/p>\n\n\n\n For maintainability, it is not ideal for one to convert all images in a website to base64 format. It just complicates matters when you want to edit your HTML code or make a change to the image. The process does not stay rosy anymore.<\/p>\n\n\n\nWhere to Use Data URIs?<\/h2>\n\n\n\n
<\/a><\/figure>\n\n\n\n
Where not to use Data URIs<\/h2>\n\n\n\n
How to Base64 Encode Images<\/h2>\n\n\n\n