Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX-Tools
 

Data URIs

 

Data URI or uniform resource identifier is a powerful "tool" added in various programming languages including JavaScript and Ajax based applications. In gist, data URI will inform the browser about the source of data as well as additional information about the data that's about to be retrieved. The URI was first introduced in 1998 but its adoption only came in HTML 4.01. The


Vs. URL


Data URI should never be confused with URL or uniform resource locator. However, you can say that a URL is also a URI because URL is simply the source of information. As already indicated, URI also provides information about the source of data and more.


Components of Data URI


Data:


mime type - this part of data URI indicates the form of data and its possible extension. The default information provided in this part of data URI is "text/plain". This can also be used in images such as "image/jpg", videos and other data format.


character set - the data encoding


Base 64 - this is the most interesting part of the data URI. This part of URI can be actually used with non-base 64 encoding if the data resource is not encoded in base 64. If the content doesn't follow the standard base 64, it will simply indicate the source of data such as the URL. However, base 64 is a 64-digit encoding that will inform the browser about the data. It's a combination of numbers, letters, plusses and slashes.


Advantages of Data URI


Easier handling of multimedia - with the data URI intact, transfer of media files will be faster and easier. Base 64 encoding eases the transfer because fewer lines are used in the application.


Less bandwidth - because base 64 files use less lines to transfer information, less bandwidth is used in the process. This allows for more information to be transferred. If the image is encoded in non-base 64 method, there could be more than 300 lines used for just a single file.


Disadvantages of Data URI


No caching features - although data URI provides the basic information about the data transferred, URIs are not cached in any browser. This means the URI should be downloaded again and again as long as the image is request in the same browser.


Re-encoding and re-embedding required - the source of data URI is still the same but if the data is changed, the URI has to be re-encoded so that it be accepted in the application. Forcing the same encoding can easily corrupt the file.


Browser Support for Data URI


Modern browsers have been supporting data URI except for IE. The support for data URI in IE only started in IE8 and based on latest reports on common browsers, IE7 is still common (some even use IE6). This means developers have to be careful in using data URI in their online application if they expect their JavaScript and Ajax based application to be publicly accessed.



Read Next: Cartographer Library



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links