Wednesday 11 September 2013

Best way to use SVG for web. Embed with PHP? [on hold]

Best way to use SVG for web. Embed with PHP? [on hold]

I think the most straightforward way is to use an img, embed, iframe or
object tag with src being the svg file, but that adds to http requests.
Suppose I have a whole bunch of svg files and I really want to optimize
speed. Using sprites is kind of a hassle. Could I use svg tags with the
svg code directly in the html. Now, that would bloat the html code and
make it less readable. However, with PHP, I could store the svg code in a
variable and dynamically add it to my html. Would that be a good idea?
What is the industry standard way to do this?
Edit: Perhaps the best way is not what I meant, but would embeding svg
code with PHP variables one of the many legit ways to do it. Each legit
way has it's advantages and drawbacks. The img with src way has the
advantage of being really simple and easy to understand but has a http
request. The embed svg way saves that http request but makes the html code
less readable. The embed with php variable keeps the code readable and no
http request, but I think it might pose some burden on the server to
assemble the dynamic page.
So, the real questions are:
How bad are the disadvantages of the embed with PHP variable are and are
there unforeseen complication?
Are there people in the industry who actually use this method already and
if no, why not?

No comments:

Post a Comment