How can I convert fonts and images (assets in general) to data attributes?
Would assets load faster or slower this way?
How can I convert fonts and images (assets in general) to data attributes?
Would assets load faster or slower this way?
You should be aware that DataURI's are not supported by IE earlier than IE8. Also, IE8 has a limitation for at most 32KB of dataURI's in css assets. A more detailed description about DataURI's can be found at this blog post.
If you need the java implementation, you can find one here:
This allow you to transform all images into a base64 encoded uri in css files. For more details about how to integrate this implementation into your project, visit this page:
Disclosure: I'm affiliated to wro4j project.
Your pages would load slower because the data has to be downloaded with each request while a separate file can be cached. Try to keep usage of data uri's for small files only.
uri encoder for images: http://www.scalora.org/projects/uriencoder/
you can use FileSystem API's readAsDataURL
meathod. But it only works in chrome for now.