Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow cache "prefilling" / preloading #8

Open
stryju opened this issue Jun 17, 2014 · 2 comments
Open

allow cache "prefilling" / preloading #8

stryju opened this issue Jun 17, 2014 · 2 comments

Comments

@stryju
Copy link
Contributor

stryju commented Jun 17, 2014

hey again ;-)

i'm starting to use the iconic set with my current angular project ad i'd like to "preload" few icons and put them into the cache.
currently, it's not available and i need to load the icons the "normal" way.

it would be great to have something like

/**
 * parses data and adds it to the cache on success
 * @param  {String}      url  url to cache it at
 * @param  {String|Node} data SVG (data or string) to parse
 * @return {Boolean}          true on success,
 *                            false on failure
 */
function preload( url, data ) {
  // ...
}

that would eventually parse the data and return Boolean result of the "preloading".

Would you implement that, or do you prefer PR?

this method would improve loading speed of my icons a bunch, since i could just inline the SVGs and "preload" them before injecting the icons :-)
what do you think?

@stryju stryju changed the title expose the cache allo cache "prefilling" / preloading Jun 17, 2014
@stryju stryju changed the title allo cache "prefilling" / preloading allow cache "prefilling" / preloading Jun 17, 2014
npbenjohnson added a commit to npbenjohnson/SVGInjector that referenced this issue Apr 17, 2016
This was referenced Apr 17, 2016
@npbenjohnson
Copy link

This is implemented and documented on my fork.
It has an optional png argument to the end of the request to allow for a fallback to be specified to override the global fallback in SVGInjector. This allows it to work with cachekeys that don't represent urls ex. "jspm:foo.svg!"

@user98765446
Copy link

@npbenjohnson I'm not JavaScript literate. Could you provide an example of what to place in the script to enable caching of the SVG. Currently, the code is working well but it reloads with the page reload, unlike the original img. I am aware that this is an old project, but any help would be most appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants