Please enable JavaScript to use CodeHS

How to use the CodeHS JS Library on your Website 2

This tutorial shows you how you can use the CodeHS Graphics JavaScript library outside of CodeHS on any website.

By Andy Bayer

Software Developer at CodeHS

<script> // put your code here! </script> </body> </html> ``` This HTML code includes the CodeHS JavaScript library (located at `https://cdn.codehs.com/chs-js-lib/0.2.21/dist/chs.iife.js`), a `canvas` element for drawing graphics, and an empty `script` tag where you'll place your code. The order of the elements here is important: the `<script>` loading the JavaScript library must come after the `canvas`, and the `<script>` containing your code must come after that. ## Step 3: Insert Your JavaScript Code The final step is to put your JavaScript code into that final `<script>` tag. For example, you might have a script like this: ```html <script> let circle = new Circle(20); add(circle); </script> ``` ## Example Here's an example showing a full HTML program for running JavaScript Graphics outside of CodeHS. We've hosted it in CodeHS, but this HTML will work on any site!">