33

I have fairly large script within an .svg file and I'd like to get it out of the CDATA section into an external file. How to achieve this?

The HTML regular does not work:

<script type="text/javascript" src="Track_animation.js" />

The documentation I have been able to find only concerns with JS embedded within the SVG itself. Is use of external scripts even possible?

Using OS X and Safari 4.0.4 for rendering.

1
  • This is regular HTML: <script type="text/javascript" src="Track_animation.js"></script>. Commented May 10, 2022 at 8:56

4 Answers 4

43

Try this

<script xlink:href="file_name" />
Sign up to request clarification or add additional context in comments.

1 Comment

<script href="file_name" /> works better for me.
20

Maybe you will need to have xmlns:xlink="http://www.w3.org/1999/xlink" as attribute in your <svg ... >.

4 Comments

Required on Firefox 44.
Required on IE 11 as well
needed in chrome 65 aswell.
Also on Chromium 80.0.3987.162
5

Seems xlink:href works (keeping the entry here, since it might help others):

<script xlink:href="Track_animation.js" />

Comments

1

Try this

<script type="text/javascript" xlink:href="svgEditarVisualizacao.js" xlink:actuate="onLoad" xlink:show="other" xlink:type="simple" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.