1

I have a normal HTML page which has loaded, how can I use Javascript to then load a dart script into the page and run the dart script? The restriction I have is that I can only load Javascript at the beginning.

I then want to load a dart script and run it.

4
  • Are you taking about JS that is converted from Dart? After building a Dart web app you don't have any Dart left. Commented Jan 14, 2014 at 10:36
  • I have a HTML web page with Javascript and no dart include into the page. Then when the user clicks a button on my page I want to load a dart file and run it. Note that when the page first loads it does not load any dart code, only when the user clicks the button I want the dart code loaded. Commented Jan 14, 2014 at 10:40
  • This only works if the user has Dartium which is the only browser available that supports Dart. Currently the Dart development workflow is: develop in Dart, test in Dart, build to JavaScript, deploy. The end user's browser normally never sees some Dart code (until a browser like Chrome, Opera, Firefox, ... contain a Dart-VM which is not likely anytime soon). Commented Jan 14, 2014 at 10:43
  • Yes its ok to assume its Dartium, but how to do it? Commented Jan 14, 2014 at 11:03

1 Answer 1

1

You can create <script> tags like below in your JavaScript and add it to your page dynamically. I haven't tried it but I can't see why it shouldn't work.

<script type="application/dart" src="yourscript.dart"></script>
<script src="packages/browser/dart.js"></script>
Sign up to request clarification or add additional context in comments.

1 Comment

Mofify the dom dynamically using Javascript to add the elements then? Ok I will try and see thanks.

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.