Data URL Maker

楼主
Data URL Maker
[P][URL=http://www.leadbbs.com/app/default.asp?id=16]http://www.leadbbs.com/app/default.asp?id=16[/URL][/P][P][URL=http://dataurl.net/#dataurlmaker]http://dataurl.net/#dataurlmaker[/URL][/P][P]
[/P][P][b]DATAURL.NET[/b] is home to some open source tools for creating and working with Data URLs([URL=http://tools.ietf.org/html/rfc2397]RFC 2397[/URL]).[/P][P]Two of these tools are [b]web-based[/b] and available here:[/P][ul][li][URL=http://dataurl.net/#dataurlmaker][b]Data URL Maker[/b][/URL] converts files to Data URLs.[/li][li][URL=http://dataurl.net/#cssoptimizer][b]Data URL CSS Optimizer[/b][/URL] optimizes CSS files by embedding external images as Data URLs.[/li][/ul][P]Various modules, code examples and GUI/command line tools for [b]UNIX systems[/b] are available in [URL=http://dataurl.net/#downloads]Downloads[/URL].[/P][P]What are Data URLs?[P]Data URLs are a Uniform Resource Identifier scheme that allow you to include data items inline in a web page as if they were being referenced as external resources. Data URLs are a form of Uniform Resource Locators, although they do not in fact remotely locate anything.Instead, the resource data is contained within the URL string itself as a [URL=http://en.wikipedia.org/wiki/Base64]base64-encoded[/URL] string. This saves the browser from having to make additional HTTP requests for the external resources, and can thus increase page loading speed.[/P]History[P]The data URL scheme was defined in [URL=http://tools.ietf.org/html/rfc2397]RFC 2397[/URL] specification of the [URL=http://www.ietf.org/]Internet Engineering Task Force[/URL].Although the IETF published the Data URL specification in 1998, it was never formally adopted as a standard. However, the HTML 4.01 specification references the data URI scheme through which Data URLs are implemented, and after years of neglect, support for Data URLs in some form or another has now been implemented in all modern browsers, including Internet Explorer 8.[/P]What do Data URLs look like?[P]Data URLs use the following syntax:[/P][blockquote]data:[mimetype][;base64],[data][/blockquote][P]Let's say we have a small file icon image we want to embed in an HTML document. In that case,we would specify a mime type identifying the image (in this case, a GIF image) followed by the base64-encoded file data:[/P][blockquote]<img width="11" height="14" src="data:image/gif;base64,R0lGOD lhCwAOAMQfAP////7+/vj4+Hh4eHd3d/v7+/Dw8HV1dfLy8ubm5vX19e3t7fr 6+nl5edra2nZ2dnx8fMHBwYODg/b29np6eujo6JGRkeHh4eTk5LCwsN3d3dfX 13Jycp2dnevr6////yH5BAEAAB8ALAAAAAALAA4AAAVq4NFw1DNAX/o9imAsB tKpxKRd1+YEWUoIiUoiEWEAApIDMLGoRCyWiKThenkwDgeGMiggDLEXQkDoTh CKNLpQDgjeAsY7MHgECgx8YR8oHwNHfwADBACGh4EDA4iGAYAEBAcQIg0Dk gcEIQA7" alt="File Icon">[/blockquote][P]This HTML tag would display the following image:[/P][blockquote][/blockquote]Advantages of Data URLs[P]Using Data URLs for the web can have several advantages:[/P][ul][li] [b]Data URLs save HTTP requests.[/b] [P]Data URLs can reduce the number of HTTP requests the browser needs to make to display an HTML document.Since the data is contained within the URL instead of being located in an external resource, no HTTP request needs to be made to display the content. Web browsers are typically configured to use somewhere between two and eight connections to a webserver at any given time. Minimizing the number of browser requests is an important component of optimizing web page loading times: Data URLs can thus have beneficial effects on performance.[/P][/li][li] [b]Faster transfer of small files[/b] [P]For transferring small files, Data URLs can result in faster downloading. Data transfers via TCP start slowly, and each external resource starts a new TCP connection to the server. The transfer speed may thus be held back by the overhead of TCP communication.[/P][/li][li] [b]Less bandwidth usage (in certain cases)[/b] [P]Data URLs use less bandwidth whenever the overhead of encoding the data as a Data URL is smaller than the overhead of an HTTP request. For example, the required base64 encoding for an image 600 bytes long would be 800 bytes, so if an HTTP request required more than 200 bytes of overhead, the data URI would be more efficient.[/P][/li][li] [b]Faster HTTPS[/b] [P]HTTPS requests have much greater overhead than ordinary HTTP requests due to SSL encryption.If your website is served over HTTPS, providing resources via Data URLs can improve performance significantly.[/P][/li][/ul]Disadvantages of Data URLs[P]The use of Data URLs has several disadvantages which should be kept in mind:[/P][ul][li] [b]Repeated occurences[/b] [P]Data URLs must repeat the string of data each time they are used within a document, so if the same resource is used multiple times, there will be increased bandwidth usage.[/P][/li][li] [b]Caching[/b] [P]Data URLs cannot be cached separately from their containing documents. They must therefore be redownloaded every time the containing document is redownloaded. This means, for example, that if a browser reloads an HTML document containing Data URLs, it must redownload all the data of embedded resources.[/P][/li][li] [b]Re-encoding for changes[/b] [P]Content must be re-encoded and re-embedded every time a change is made. The hassle this entails can be minimized by using some of the free software available on this website.However, you won't want to start using Data URLs until the development process for your website is complete.[/P][/li][li] [b]No support in old versions of Internet Explorer[/b] [P]Internet Explorer versions prior to version 8 do not support Data URLs at all. There are several work-arounds for this, whereby you can gain the benefits of Data URLs for other browsers while serving older browsers traditional images.[/P][/li][li] [b]Base64 encoding increases data size[/b] [P]Base64-encoded Data URLs are 33% larger in size than their binary counterparts. However, if you use gzip content encoding on your webserver, this is reduced to between 0-10%.[/P][/li][li] [b]Size limitations[/b] [P]According to the Data URL specification, browsers need only support Data URLs up to 1024 bytes long.Most browsers, however, will accept much larger ones. Opera limits Data URLs to about 4100 characters,Firefox (Mozilla ) up to 100 KB, Internet Explorer about 32 KB, and WebKit (Safari) doesn't seem to have any limit at all. Typically, however, the benefits of using Data URLs disappear at with larger images,so they are best used only for small (~1-4KB) images.[/P][/li][/ul]Browser support[P]Data URIs are currently supported by the following web browsers:[/P][ul][li]Firefox and all browsers that use the Mozilla Foundation's Gecko rendering engine[/li][li]Safari, Chrome and other WebKit-based browsers[/li][li]Opera[/li][li]Konqueror[/li][li]Internet Explorer 8+ (with certain limitations)[/li][/ul][P][/P]

电脑版 Page created in 0.1719 seconds with 4 queries.