# JSFiddle Docs & Help

{% content-ref url="/pages/-L9jXjJ6H0NdJSzp-Uqo" %}
[Getting started](/getting-started)
{% endcontent-ref %}

{% content-ref url="/pages/-LNuoSRx521ek62mL\_wH" %}
[Panels settings](/panels-settings)
{% endcontent-ref %}

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td></td><td></td><td></td><td><a href="/editor-settings">Editor settings</a></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>


# Getting started

How to get started with JSFiddle.

## New fiddle or a Boilerplate

Opening an empty fiddle will give you the option to start fresh or create a fiddle from our boilerplates:

![](https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LNu_TN1FjMCmA_viUv1%2F-LNub2Y_k9L1Abt11dxs%2FScreen%20Shot%202018-10-03%20at%2017.45.55.png?alt=media\&token=f90eac6c-515a-4443-b448-5831bd90ce01)

## Entering and running code

JSFiddle has the notion of panels (or tabs if you switch into the tabbed layout), there are 4 panels, 3 where you can enter code, and 1 to see the result.

* **HTML** - structure code, no need to add `body` `doctype` `head`, that's added automatically
* **CSS** - styles. You can switch pre-pocessor to SCSS
* **JavaScript** - behavior. There are many frameworks and code pre-processors you can use

Once you enter code, just hit **Run** in the top actions bar, and the fourth panel with results will appear.&#x20;

## Saving and Forking code

* **Save** / **Update** will do what you think, it'll save a new fiddle or update an existing one (and add a version number to it)
* **Fork** will split out an existing fiddle into a new one, starting with version 0&#x20;

## Setting fiddle as Base Version

{% hint style="info" %}
This action is available for **logged in users only**.
{% endhint %}

If you're working a fiddle and updating it, the version number will increase, sometimes if you're satisfied with the code you have it's good to save it so that the version numbers are hidden, and the version you've set as base is the default one.

For example if you have a fiddle `jsfiddle.net/oskar/aba321/23` setting as base will make the 23 version accessible at `jsfiddle.net/oskar/aba321`

{% hint style="info" %}
When you save a **new title or description** for the fiddle, saving it will not result in any change on your dashboard, **you need to set the fiddle as Base for the new title and description to appear**. &#x20;
{% endhint %}


# Panels settings

Each panel has their own settings

## HTML panel

* **Language** – currently not available
* **Doctype** – documents doctype, ie. HTML5, XHTML, etc
* **Body tag** – usually done to change the styling as `<body class="dark_ui">`. Some frameworks (Dojo) are using it to style the widgets and load CSS

<div align="left"><img src="https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LNucb1zcqduazWl7IwO%2F-LNuruKlxbsTTHl0tXfu%2FScreen%20Shot%202018-10-03%20at%2018.59.49.png?alt=media&amp;token=8589c0e9-ae8f-4c80-aef6-b8c4f70aea15" alt=""></div>

## CSS panel

* **Language** – change the pre-processor, right now only **CSS** and **SCSS**
* **Options** – additional options, like the ability to **Normalize CSS**

<div align="left"><img src="https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LNucb1zcqduazWl7IwO%2F-LNus7bM0uXASSNp-j_G%2FScreen%20Shot%202018-10-03%20at%2019.00.02.png?alt=media&amp;token=83bb2c94-6640-486c-b313-651788927f31" alt=""></div>

## JavaScript panel

* **Language** – Pre-processor, ie **CoffeeScript**, **TypeScript**, **Babel**, **Vue**, **React**, etc.
* **Frameworks & Extensions** – many commonly used JS frameworks (and their extensions)
* **Framework** `<script>` **attribute** – attribute added to the included framework script tag, ie `<script src="..." data-angular-custom-thingy>`
* **Load type** – the way JS is loaded in the editor – see table below for details:

| Load type                       | Description                                                          |
| ------------------------------- | -------------------------------------------------------------------- |
| **On Load**                     | wrap the code so it will run in *onLoad* window event                |
| **On DOM Ready**                | wrap the code so it will run in *onDomReady* window event            |
| **No wrap - bottom of \<head>** | *do not wrap* the JavaScript code, place it in the bottom of \<head> |
| **No wrap - bottom of \<body>** | *do not wrap* the JavaScript code, place it in the bottom of \<body> |

<div align="left"><img src="https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LNucb1zcqduazWl7IwO%2F-LNusCG760910icV9BQS%2FScreen%20Shot%202018-10-03%20at%2019.00.12.png?alt=media&amp;token=09f357b5-641f-4cbb-8d74-ee4631ba2f59" alt=""></div>


# Editor settings

## Layout and themes

JSFiddle allows you to switch the layout of the editor from the classic 2x2 grid to something that suits your needs. In addition to the grids mode it also has a **tabbed mode**.

**Grids are fully resizable**. As an addition resizing the **Results panel will tell you its width** (handy for working on **media queries**).

~~There are two themes to choose from: **Dark** (default) and **Light**.~~ Light theme has been retired.

<div align="left"><img src="https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LO2LyLBPI6vhaAiMS5Z%2F-LO2MzOsvBnfMr2C4R3E%2FKapture%202018-10-05%20at%2010.36.37.gif?alt=media&amp;token=5c328c2b-895d-40cc-a9fc-b4bb3262971d" alt=""></div>

## General&#x20;


# Fiddle meta

Right now meta means the title and description.

* **Title** – Title of the fiddle will be displayed on your public profile. ~~adding title will also make the fiddle available on your public profile page, normally when that's not set it'll be unlisted (not displayed in Public Fiddles listing, but anyone who has a direct link to the fiddle will be able to access it)~~
* **Description** – well, the description of the fiddle. It will be displayed in your public fiddle list.


# External resources

You can add external resources like CSS and JavaScript to your fiddle.

Add resource by:

* **URL from the web** – this will embed the specific URL in your fiddle.
* **CDNJS** – just start typing a library name and an autocompelete will suggest libraries you and insert:

<div align="left"><img src="https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LNuvL1vej_AskUMtWKN%2F-LNuwihcYBma-xFz4Z23%2FKapture%202018-10-03%20at%2019.20.30.gif?alt=media&amp;token=12288fd4-5678-4647-aa66-de79dbe5e08e" alt=""></div>

{% hint style="info" %}
&#x20;If you want to use a dynamic resource please add a dummy GET variable i.e. `http://example.com/dynamically.php?somevar=somevalue&dummy=.css`. This will tell JSFiddle to recognize it as a CSS resource.
{% endhint %}


# Embedding fiddles

Embedding is provided to show the fiddle with running result on any other page.

Embedding is available from the action menu.

<div align="left"><img src="https://2867931111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jXGYtvV0gDWqyZIc-%2F-LNxyB7v7Cq67LetJzfq%2F-LNyTNBOz29tKZvdED-u%2FKapture%202018-10-04%20at%2011.46.55.gif?alt=media&amp;token=f48ecb3b-cdb0-404a-8e29-b891271d6d15" alt=""></div>

### Embed has a few visual options:

* **Tabs** – pick which tabs to include in the embed. Order can be changed by changing the string `js,css,html,results` in the URL – more below.
* **Visual** – Light or dark theme, and specific color accents (hex code)
* **Embed snippet** – embed can be used as an `iframe` or `script`. The benefit of using `script` is that it's not blocking rendering and height can be automatically adjusted, so it fits the code in each tab.

### Changing tabs order

In example if to show the result as the first tab add `result,js,html,css` to the URL: `<iframe src="http://jsfiddle.net/zalun/NmudS/embedded/result,js,html,css/">`


# Async requests

To improve user experience **Echo** features has been created. This allows to test asynchronous requests, add javascript files, create workers - all from one fiddle, so it is more transparent for the user reading the code.&#x20;

Asynchronous requests are split to **HTML**, **JSON**, **JSONP** and **XML**. [*Gist*](http://doc.jsfiddle.net/use/gist_response.html#gist-response) and [*github*](http://doc.jsfiddle.net/use/github_response.html#github-response) responses are similar to the echo feature and go nicely in pair with storing fiddles in [*gist*](http://doc.jsfiddle.net/use/gist_read.html#gist-read) and [*github*](http://doc.jsfiddle.net/use/github_read.html#github-read).

## HTML

**URL:** `/echo/html/`

{% hint style="info" %}
Data has to be provided via **POST**.
{% endhint %}

| Option key | Description                                                           |
| ---------- | --------------------------------------------------------------------- |
| **html**   | Data has to be provided via POST                                      |
| **delay**  | (Optional) It’s a time in seconds after which data should be returned |

{% embed url="<https://jsfiddle.net/6he52mnr/1/>" %}

## JSON

{% hint style="info" %}
Data has to be provided via **POST**.
{% endhint %}

**URL:** `/echo/json/`

| Option key | Descriptio                                                                                                    |
| ---------- | ------------------------------------------------------------------------------------------------------------- |
| **json**   | JSON string representing the object jsFiddle should return. It has to be valid JSON or error will be returned |
| **delay**  | (Optional) It’s a time in seconds after which data should be returned                                         |

\[Missing embed]

## JSONP

{% hint style="info" %}
Data has to be provided via **GET**. JSFiddle will respond all data given in request. It uses URL **with host and protocol** as it’s loaded from different domain. `callback` and `delay` will not be returned.
{% endhint %}

**URL:** `https://jsfiddle.net/echo/jsonp/`

| Option key   | Description                                                           |
| ------------ | --------------------------------------------------------------------- |
| **callback** | name of the jsonp function                                            |
| **delay**    | (Optional) It’s a time in seconds after which data should be returned |

\[Missing embed]

## XML

{% hint style="info" %}
Data has to be provided via **POST**
{% endhint %}

**URL:** `/echo/xml/`

| Option key | Description                                                           |
| ---------- | --------------------------------------------------------------------- |
| **xml**    | Valid string representing XML code                                    |
| **delay**  | (Optional) It’s a time in seconds after which data should be returned |

\[Missing embed]


# Github Integration

JSFiddle allows some integration with Github


# Display fiddle from a Github repository

This allows you to skip the part of hosting code on JSFiddle and load it directly into the editor from a Github repository.

## Demo directory structure

```
Demo Directory/
  demo.js
  demo.html
  demo.css
  demo.details
```

* **demo.\[ js | html | css ]** contains fiddle code for the specific panel
* **demo.details** is a description of the demo written in YAML

```
---
 name: Name of the Demo
 description: Some description, please keep it in one line
 authors:
   - John Doe
   - Jan Wisniewski
 resources:
   - http://some.url.com/some/file.js
   - http://other.url.com/other_filename.css
 normalize_css: no
 load_type: d
 ...
 
```

{% hint style="info" %}
All fields are optional
{% endhint %}

## Running demo in JSFiddle

URL segments in examples:

* `framework` – the desired framework to load along the code from repo
* `version` – substring of the framework version - the last passing will be used. If 1.3 will be given, JSFiddle will use the latest search result. it will favorize 1.3.2 over 1.3.1 and 1.3
* `dependency_list` – comma separated list of dependency substrings. It would mark any dependency containing the substring
* `github_tree` – the path to the directory used to display it on github page (without `http://github.com/`)

### Demo + no JS framework

For no framework and version use `library/pure`:

```
https://jsfiddle.net/gh/get/library/pure/{github_tree}/
```

{% hint style="info" %}
**Example:** <https://jsfiddle.net/gh/get/library/pure/{github_tree}/>
{% endhint %}

### Demo + JS framework with a version

Demo with a preset framework (for example jQuery 3.0):

```
https://jsfiddle.net/gh/get/{framework}/{version}/{github_tree}/
```

{% hint style="info" %}
**Example:** <https://jsfiddle.net/gh/get/jquery/3.0/{github_tree}>

This demo is fetched from the following repo:

<http://github.com/zalun/jsFiddleGithubDemo/tree/master/Demo/>
{% endhint %}

### Demo + JS framework with version + dependencies

Demo with a framework and external resources/dependencies

```
https://jsfiddle.net/gh/get/{framework}/{version}/dependencies/{dependency_list}/{github_tree}/
```

{% hint style="info" %}
**Example: #TODO**
{% endhint %}


# Display fiddle from Gist

Read a demo from Github Gist and present it as a fiddle.

## Gist files structure

```
fiddle.js
fiddle.html 
fiddle.css 
fiddle.manifest
```

| File name                 | Description                                                       |
| ------------------------- | ----------------------------------------------------------------- |
| **fiddle.\[js/html/css]** | Contains fiddle code for the specific panel                       |
| **fiddle.manifest**       | <p>YAML description of the Gist for JSFiddle to parse<br><br></p> |

### Manifest file example

```yaml
name: The Name of the Fiddle
description: Some description, please keep it in one line
authors:
  - John Doe
  - Jan Wisniewski
resources:
  - http://some.url.com/some/file.js
  - http://other.url.com/other_filename.css
normalize_css: no
wrap: b
panel_js: 1
panel_css: 1
```

{% hint style="info" %}
All  fields are optional.
{% endhint %}

### Manifest fields

* `panel_html` – Language for HTML panel. Accepts:
  * `0` – HTML
* `panel_css` – Language for CSS panel. Accepts:
  * `0` – CSS
  * `1` – SCSS
* `panel_js` – Language for the JS panel. Accepts:
  * `0` – JavaScript
  * `1` – CoffeeScript
  * `2` – JavaScript 1.7
* `resources` – List of external resources.
* `name` – Fiddle title
* `description` – Fiddle description
* `normalize_css` – Normalize CSS by loading normalize.css before any CSS declarations.
  * `yes` – normalize
  * `no` – don't normalize
* `wrap` – Set the JS code wrap. Options:
  * `l` – On load
  * `d` – On DOM ready
  *

| Field          | Description |
| -------------- | ----------- |
|                |             |
| name           |             |
| description    |             |
| normalize\_css |             |
| wrap           |             |


# Pass response directly from a Github repo

While the demo might use an Async requests, JSFiddle will read them and send using the right MIME type.

## Demo directory structure

```
Demo Directory/
  demo.response.html
  demo.response.json
  demo.response.xml
```

## Running demo in JSFiddle

```
https://jsfiddle.net/gh/get/response.{extension}/{github_tree}/
```

URL segments in examples:

* `extension` – the file extension of the demo.response.{extension} in github demo repository.
* `github_tree` – the path to the directory used to display it on github page (without `http://github.com/`).

{% hint style="info" %}
There is no JSONP functionality provided. One may achieve it using raw GitHub URL.
{% endhint %}

## Example

Content of:

`http://github.com/zalun/jsFiddleGithubDdemo/raw/master/Demo/demo.response.html`

will be returned with **text/html** MIME type if this URL will be loaded from:

`https://jsfiddle.net/gh/get/response.html/zalun/jsFiddleGithubDemo/tree/master/Demo/`

{% hint style="info" %}
**Example:**&#x20;

<http://jsfiddle.net/gh/get/mootools/1.2/zalun/jsFiddleGithubDemo/tree/master/Demo/>
{% endhint %}


# Pass response directly from Gist


# Displaying user fiddles

It allows to create plugins displaying fiddles created by specific user

<mark style="color:blue;">`GET`</mark> `https://jsfiddle.net/api/user/:username/demo/list.json`

#### Query Parameters

| Name      | Type    | Description                                                                                                                         |
| --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| callback  | string  | <p>Function name for cross-domain. If no callback is provided, standard JSON will be returned.<br><br>Default: None</p>             |
| start     | integer | <p>Offeset element.<br><br>Default: <code>0</code></p>                                                                              |
| limit     | integer | <p>Number of elements to return.<br><br>Default: <code>10</code></p>                                                                |
| sort      | string  | <p>Sorting type.<br><br><code>date</code>, <code>alphabetical</code> or <code>framwork</code><br><br>Default: <code>date</code></p> |
| order     | string  | <p><code>desc</code> or <code>asc</code><br><br>Default: <code>asc</code></p>                                                       |
| framework | string  | <p>Filter framework.<br><br>Default: None</p>                                                                                       |

{% tabs %}
{% tab title="200 " %}

```javascript
Api({
  "status": "ok",
  "list": [
    {
      "description": "...",
      "author": "{username}",
      "url": "...",
      "created": "...",
      "framework": "...",
      "version": 123,              // base version number
      "latest_version": 234,       // latest version number
      "title": "..."
    },
    // ...
  ],
  "overallResultSetCount": 12      // number of the results
});
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Example:

<http://jsfiddle.net/api/user/zalun/demo/list.json?callback=Api&sort=framework&start=5&limit=5>
{% endhint %}


# Display a fiddle from POST

It's possible to display a fiddle that's not saved in JSFiddle, using a POST from a 3rd-party source

## URL Structure

* **framework** – the desired framework name. Which framework should be loaded with the fiddle.
* **version** – substring of the framework version - the last passing will be used. If 1.3 will be given, JSFiddle will use the latest search result. it will favorize 1.3.2 over 1.3.1 and 1.3.
* **dependency\_list** – comma separated list of dependency substrings. It would mark any dependency containing the substring.

### Framework

The framewrok to load (or the lack of it) has to be specified in the URL, for example: `jsfiddle.net/api/post/{framework}/{version}`

If you don't want to use a framework use `library/pure`, for example: `jsfiddle.net/api/post/library/pure/`

### Dependencies

There is an option to add dependencies as a comma separated list: `jsfiddle.net/api/post/{framework}/{version}/dependencies/{dependency_list}/`<br>

## POST variables

All fields are optional. New fiddle setting will be used if no data provided.

<mark style="color:green;">`POST`</mark> `https://jsfiddle.net/api/post/:framework/:version/dependencies/:dependency_list/`

#### Request Body

| Name           | Type    | Description                                                                                                                                                                                                                                                              |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| normalize\_css | string  | `yes` or `no` - should `normalize.css` be loaded                                                                                                                                                                                                                         |
| wrap           | string  | <p>Set the JS code wrap:<br><br>Accepts:<br><br>- <code>l</code> for <code>onload</code><br>- <code>d</code> for <code>domready</code><br>- <code>h</code> for no wrap at bottom of <code>HEAD</code><br>- <code>b</code> for no wrap at bottom of <code>BODY</code></p> |
| html           | string  | code for the HTML panel                                                                                                                                                                                                                                                  |
| css            | string  | code for the CSS panel                                                                                                                                                                                                                                                   |
| js             | string  | code for the JS panel                                                                                                                                                                                                                                                    |
| html\_panel    | integer | <p>language for the HTML panel.<br><br>Accepts <code>0</code> only.</p>                                                                                                                                                                                                  |
| css\_panel     | integer | <p>language for the CSS panel.<br><br>Accepts:<br>- <code>0</code> for <strong>CSS</strong><br>- <code>1</code> for <strong>SCSS</strong></p>                                                                                                                            |
| js\_panel      | integer | <p>language for the JS panel<br><br>Accepts:<br>- <code>0</code> for <strong>JavaScript</strong><br>- <code>1</code> for <strong>CoffeeScript</strong><br>- <code>2</code> for <strong>JavaScript 1.7</strong><br>- <code>3</code> for </p>                              |
| title          | string  | Title of the fiddle                                                                                                                                                                                                                                                      |
| description    | string  | Description of the fiddle                                                                                                                                                                                                                                                |
| dtd            | string  | <p>Documents definition type.<br><br>Accepts a substring of the chosen DTD (ie <code>html 4</code>).<br></p>                                                                                                                                                             |
| resources      | string  | a comma separated list of external resources                                                                                                                                                                                                                             |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Example:**

<http://jsfiddle.net/3Lwgk4c5/>
{% endhint %}


# Get username

Replies the username of the logged in user.

## get\_username

<mark style="color:blue;">`GET`</mark> `http://jsfiddle.net/user/get_username/`

Responds with the logged in users username

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
oskar
```

{% endtab %}
{% endtabs %}


# Demos for products or libraries

Lots of people and companies use JSFiddle for online examples of their JavaScript libraries/products.

## Here are some companies that use JSFiddle for their examples:

* Highcharts Docs
* Mozilla Developer Network
* Google Docs
* BrowserStack
* Stripe (internally)
* Shopify (internally)
* Vue.js (fiddle embedding inside of docs)
* Element (Vue 2.0 based component library)
* StackOverflow


# Bug reporting (test-case) for Github Issues


# Answers on Stack Overflow


# Live code collaboration


# Conducting live interviews for developer positions

Many companies use JSFiddle for conducting live interviews for developer positions at their companies.

Interviewers set up some sample code or give a code test to solve, [turn on collaboration](/use-cases/live-code-collaboration), invite the interviewee which then allows the company to **see the flow and coding process of the candidate**.


# Code snippets hosting


