-
Notifications
You must be signed in to change notification settings - Fork 5
Data Uri's
The Data URI scheme can be used to include binary data in a web page; and Moth supports Data URIs for images. The great thing about this technique is that you can include your images into your webpage, and thus won't have to do new requests for those images.
The syntax is fairly easy, and is exposed as an extra method on the Html
object:
<%= Html.DataUriImage("~/content/images/fundalogo.gif") %>
The path can be either relative (by starting with a tilde), or absolute (starting with http://); as long as the webserver can access the absolute path.
Data URIs are supported by all modern browsers (Firefox, Chrome, IE 8 and up), and all major mobile browsers. For browsers that don't support the scheme, a fallback will be activated automatically. Note that IE 8 currently only supports images that are smaller dan 32 KiB. Limit the size of your images therefore to max. 32 KiB.
To call <%= Html.RenderScripts(); %>
at the bottom of your masterpage, for the images to render. See the Javascript section.