> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abtestly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Code history

> Every saved version of a variation's JavaScript, CSS and libraries, kept for the life of the experiment. Compare any two, see what changed since launch or the last reset, and restore an older version as a draft.

ABTestly keeps a version of a variation's code every time its JavaScript,
CSS or attached libraries change. **History** answers three questions inside
the dashboard: what did this variation look like when the test launched, what
has changed since, and how do I get an older version back.

Versions are stored in full and kept for as long as the experiment exists.
There is nothing to set up. An experiment that existed before code history
starts with one version of each variation's code as it was then.

## Open History

<Steps>
  <Step title="Open the variation's code">
    On the experiment page, open a variation's code with the code button on
    its row (its tooltip reads **Show code**).
  </Step>

  <Step title="Click History">
    **History** sits above the code, in the read view and in the editor. Its
    tooltip reads **Version history**.
  </Step>
</Steps>

A panel opens on the right, titled **History:** and the variation's name. It
lists the stored versions newest first, 50 at a time. **Load older versions**
at the bottom fetches the next 50.

Anyone who can open the experiment can open History and compare versions,
Viewers included. Restoring needs more, see
[who can see and restore](#who-can-see-and-restore).

## What each version shows

| Part   | What you see                                                                                    | What it means                                                                                                                                                                                                                    |
| ------ | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Number | **Revision 4**                                                                                  | Versions are numbered from 1 for each variation. Numbers are never reused                                                                                                                                                        |
| Author | A first name, or an email address when there is no first name                                   | Who saved it. **Code before history began** marks a Baseline version. **Author not recorded** marks a Recovered version, which has no author on record. **Former member** means the person who saved it no longer has an account |
| Time   | How long ago, such as **25m ago** or **2d ago**, or a date such as **Sep 3** for older versions | When the version was stored. Hover for the full date and time                                                                                                                                                                    |
| Status | **Live**, **Draft**, **Scheduled**, **Paused**, **Archived** or **Completed**                   | The experiment's status when the version was stored. A running experiment shows as **Live**                                                                                                                                      |
| Source | See the next table                                                                              | How the version was stored                                                                                                                                                                                                       |
| Badge  | **Data reset**                                                                                  | The save that stored this version also reset the experiment's data, because you chose **Reset and continue**                                                                                                                     |

A reset from the **Reset data** button changes no code, so it stores no
version and no badge.

### Sources

| Label            | Stored when                                                                                                                                                     |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Saved**        | Someone saved a change to the code or the libraries, from the inline editor or the experiment editor. Saving a restored version is a save too                   |
| **Created**      | The experiment was created. Every variation, the Original included, starts at revision 1                                                                        |
| **Cloned**       | The experiment was [cloned](/build/clone). The clone's history starts here. The source experiment keeps its own history                                         |
| **From Signals** | The experiment was drafted from a Signals scan. See [Build a test from a scan](/signals/build-a-test)                                                           |
| **Baseline**     | The code as it was before history began. Every variation of an experiment that existed before code history starts with one, dated at that variation's last save |
| **Recovered**    | ABTestly found saved code missing from the history and added it. See [why a version says Recovered](#why-does-a-version-say-recovered)                          |

### Current (not yet in history)

Sometimes the list starts with an entry named **Current (not yet in
history)**. It is the variation's code as the page loaded it, shown when that
code differs from the newest stored version, or when nothing is stored yet.
You can compare it like any other version. It has no Restore button, since it
is the saved code.

It appears for one of two reasons:

* **A save went through, but storing its version did not.** The save itself
  is never affected. The missing code is added as a **Recovered** version (a
  **Baseline**, if the variation had no versions yet) the next time the
  experiment's variations are saved. Launching the experiment, a scheduled
  start, and a data reset from **Reset data** or from **Reset and continue**
  when you resume also add it.
* **Someone saved after you opened the page.** Your page then holds older
  code than the newest version. Reload the page.

## Compare two versions

<Steps>
  <Step title="Tick two versions">
    Tick the checkbox on any two entries. Ticking a third one drops the one
    you ticked first.
  </Step>

  <Step title="Read the comparison">
    The comparison opens above the list, headed for example **Comparing
    revision 3 with revision 5**. The older version is always on the left
    and the newer one on the right, whatever order you ticked them in. The
    current code is always the newer side.
  </Step>

  <Step title="Switch files">
    **variation.js** and **variation.css** switch which file you compare.
  </Step>
</Steps>

Comparisons in History are read only. Close one with its close button (×) or
Esc. The list stays as it was and the focus goes back to the checkbox or
button that opened the comparison. In the panel, Esc closes an open
comparison first. With no comparison open, Esc closes the panel.

When the two versions have different libraries, a line under the
**Comparing revision** heading names the difference, in the same format as
[Review changes](/build/review-changes#library-changes):
`Libraries: adds <key>; removes <key>`, or
`Libraries: same libraries in a new load order`. It reads from the older
version to the newer one, so **adds** means the newer version has a library
the older one does not. When the libraries are the same, no line shows.

<Frame caption="Revision 5 and revision 6 compared in History. The older version is always on the left. Below the comparison, each version shows its author, time, status and source.">
  <img src="https://mintcdn.com/abtestly/2ef-8o-PecV6cU5l/images/code-history-compare.png?fit=max&auto=format&n=2ef-8o-PecV6cU5l&q=85&s=4b24c836b3794ec740423402ff1f30d3" alt="History panel for Variant B comparing revision 5 with revision 6 side by side, above a list of six versions with revision 5 and revision 6 ticked" width="2400" height="1633" data-path="images/code-history-compare.png" />
</Frame>

## Quick picks

Three buttons under the panel title pick a comparison for you.

| Button               | When it shows                                                | What it compares                                                                      |
| -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| **Previous save**    | Always. Disabled until the variation has two stored versions | The two newest stored versions, whatever stored them                                  |
| **Since launch**     | Once the experiment has started                              | The version that was current when the experiment first started, with the current code |
| **Since last reset** | Once the experiment's data has been reset                    | The version that was current at the last data reset, with the current code            |

"The version that was current" at a moment means: of all the versions stored
at or before that moment, the most recent one. Launch is the first start,
from draft or scheduled to running. Pausing and resuming does not move it.

The quick picks load older versions for you when the moment falls further
back than the list shows, up to 2,000 more.

<Frame caption="Since launch on a variation whose code has not changed since the test started. The note reads No code changes since launch, and only the version current at launch is selected. It is already the saved code, so there is nothing to compare.">
  <img src="https://mintcdn.com/abtestly/2ef-8o-PecV6cU5l/images/since-launch.png?fit=max&auto=format&n=2ef-8o-PecV6cU5l&q=85&s=63db7347d6b7f7292344efa155303f25" alt="History panel after Since launch, with the note No code changes since launch under the quick pick buttons and only revision 4 ticked" width="2400" height="1133" data-path="images/since-launch.png" />
</Frame>

### Notes under the buttons

| Note                                                                                              | What it means                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **No code changes since launch**                                                                  | The code now is the code at launch. Only that version is selected, because there is nothing to compare                                                                      |
| **No code changes since the last reset**                                                          | The same, for the last reset                                                                                                                                                |
| **History starts on** and a date                                                                  | The launch or reset happened before the oldest stored version, so the oldest version is compared instead. The date shows in your browser's format, for example Jul 14, 2026 |
| **Showing the latest** and a number of versions, then **Load older versions to go further back.** | The history is longer than a quick pick loads, and the moment falls before everything loaded. Click **Load older versions** and pick again                                  |
| **No saved versions to compare yet**                                                              | The variation has no stored versions                                                                                                                                        |
| **Couldn't read the launch date** or **Couldn't read the reset date**                             | The experiment's date could not be read. Reload the page                                                                                                                    |

## Restore an older version

<Steps>
  <Step title="Click Restore this version">
    In History, on the version you want back.
  </Step>

  <Step title="Check the draft">
    The panel closes and the variation's code opens in the editor with that
    version loaded as an unsaved draft. When it differs from the saved code,
    Review changes is already on, open on a file that changed, and the button
    reads **Back to editor**.
  </Step>

  <Step title="Save it, or cancel">
    Nothing is saved until you click **Save**. **Cancel** drops the draft
    and leaves the saved code as it was.
  </Step>
</Steps>

* **A version that differs only in its libraries** opens in Review changes
  with the same code on both sides. The library line under the header names
  what the restore adds or removes. See
  [library changes](/build/review-changes#library-changes).
* **A version identical to the saved code**, with the same JavaScript, CSS
  and libraries, has nothing to restore. Its button is disabled with the
  tooltip **This is already the saved code.**, and the same words show on its
  row. That happens once its code has been loaded, for example by comparing
  it. If you click Restore before that, the panel says so and restores
  nothing.
* **The save is an ordinary save.** It goes through every check any save
  does: your access, the lock, the reset or keep data question, the library
  rules, the syntax check and [code check](/build/code-check). Restoring is
  never a way around one of them.

<Frame caption="A restored version opens as an unsaved draft in Review changes, with the saved code on the left. This one also adds a library, named in the line under the header.">
  <img src="https://mintcdn.com/abtestly/2ef-8o-PecV6cU5l/images/restore-review-libraries.png?fit=max&auto=format&n=2ef-8o-PecV6cU5l&q=85&s=3b97658978716c09acc3ad9a63384e50" alt="Inline editor in Review changes after a restore, with the line Libraries: adds dayjs under the header and the saved code next to the restored version" width="2400" height="1033" data-path="images/restore-review-libraries.png" />
</Frame>

### When Restore is unavailable

When you cannot restore, the panel says why near the top and every **Restore
this version** button is disabled with the same words as its tooltip. The
reasons are checked in this order:

| Message                                                                                           | Why                                                                                                         | What to do                                                                 |
| ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| **Viewers can't restore versions.**                                                               | You are a Viewer. Viewers can open History and compare                                                      | Ask a Dev or an Admin                                                      |
| **You need code editor access to restore versions. Ask an admin to grant it from Team & access.** | You do not have **Code editor access** on this site                                                         | Ask an Admin for **Code editor access** on the site                        |
| **This experiment is archived, so its code can't be restored.**                                   | Archived experiments cannot be edited                                                                       | [Clone](/build/clone) the experiment and work on the code in the new draft |
| **You can't edit this experiment's code.**                                                        | The experiment is running or paused, so saving its code republishes it, and you cannot publish on this site | Ask an Admin for **Publish experiments** on the site                       |
| **This experiment is locked for editing. Pause it first, then restore.**                          | The running experiment has 1,000 visitors since its last reset                                              | Pause it, restore, save, then answer the reset or keep data question       |
| **Save or cancel your open edit first.**                                                          | The inline editor is open with unsaved changes, on this variation or another one                            | Save or cancel that edit                                                   |
| **An unsaved draft is waiting. Recover or discard it in the editor first.**                       | A recovery banner is waiting, or this variation has an autosaved draft from an earlier visit                | Open that variation's editor and click **Recover** or **Discard**          |

The last two exist so a restore never overwrites work you have not saved.
Autosave would replace a waiting draft with the restored code within about a
second, before you ever saw it.

The panel checks again when a version's code arrives. If something changed
while it loaded, for example you started typing, you see **Can't restore this
version** with the reason, and nothing changes.

### Libraries in a restored version

A version holds its library keys as well as its code, and restoring brings
them back. **Save** sends them with the code, and the save applies the usual
library rules:

* A library the variation already has is kept, even if it has been deprecated
  since.
* A library the variation does not have now counts as newly attached. That
  needs Dev libraries on your plan (**Pro and above**) and the library
  approved for the site under **Site → Developer libraries**. Otherwise the
  save is refused and nothing is stored. Remove the library in **Libraries**,
  or approve it, then save again.

See [Dev libraries](/build/dev-libraries).

### Autosave keeps a restored draft

After a restore, autosave treats the restored code as your draft and mirrors
it to this browser within about a second, the same as your typing. It keeps
the libraries too when they differ from the saved ones. If the page reloads
before you save, the recovery banner offers the draft back, and **Recover**
puts back the code and the libraries.

If someone saves the variation in the meantime, the banner warns **Unsaved
changes found, but the saved code has changed** and the button reads
**Recover anyway**, because recovering replaces the newer saved code with your
draft. The same warning appears when your draft changed the libraries and
someone has since changed the saved libraries. Use **Compare with saved** in
the banner to see both first. See
[Autosave and drafts](/build/autosave#recovering-an-unsaved-draft).

## Reference

### What stores a version

| Event                                                                                                                | Source label     |
| -------------------------------------------------------------------------------------------------------------------- | ---------------- |
| A save that changes the JavaScript, the CSS or the library keys, from either editor. A new library load order counts | **Saved**        |
| Creating an experiment, one version per variation                                                                    | **Created**      |
| Cloning an experiment, one version per variation of the clone                                                        | **Cloned**       |
| Drafting an experiment from a Signals scan                                                                           | **From Signals** |
| History beginning on an experiment that already existed                                                              | **Baseline**     |
| Finding saved code that is missing from the history                                                                  | **Recovered**    |

These store nothing new:

* A save that leaves the code and the libraries as they were. Changing only a
  variation's weight or name, the goals, the targeting, the schedule or the
  traffic split stores no version.
* Starting, pausing, resuming or archiving the experiment.
* Autosave. Drafts in your browser never reach history.
* Restoring. Only the save after it stores a version.

A variation's name is not part of a version, so renaming one stores nothing.
The panel title uses the name it has now.

If you remove a variation, its versions are kept, but History is only offered
on variations the experiment still has.

### Who can see and restore

|                                   | Admin | Dev                                                                                                | Viewer                        |
| --------------------------------- | ----- | -------------------------------------------------------------------------------------------------- | ----------------------------- |
| Open History and compare versions | Yes   | Yes, on sites they can access                                                                      | Yes, on sites they can access |
| Restore a version into the editor | Yes   | With **Code editor access**, when they can edit the experiment's code                              | No                            |
| Save the restored version         | Yes   | With **Code editor access**, plus **Publish experiments** when the experiment is running or paused | No                            |

A member scoped to some sites cannot open History for experiments on other
sites. See [Members and roles](/team/members-and-roles) and the
[Permissions catalog](/team/permissions-catalog).

### Retention and limits

* **Kept for the life of the experiment.** Nothing is pruned on a timer.
* **Stored in full.** Each file can be up to 500,000 characters, the same
  limit a save has. A version is never shortened.
* **Archiving keeps them.** Versions are deleted when the experiment is
  permanently deleted, when its site is deleted, and when the account is
  closed.

The [Activity log](/team/activity-log#code-changes) also shows code changes,
but it keeps workspace changes for 6 months only, and it does not keep a file
over 32 KB in full. Code history is the complete record.

### Keyboard shortcuts

| Keys                    | Where                                                                                                           | What happens                                                                                                                                        |
| ----------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ctrl+S (Cmd+S on a Mac) | The inline editor, or its Review changes comparison                                                             | Saves the variation                                                                                                                                 |
| Ctrl+S (Cmd+S)          | Compare with saved in the experiment editor                                                                     | Nothing. Save with the experiment editor's own button                                                                                               |
| Esc                     | Any comparison with a close button: Review changes, Compare with saved, a recovered draft, a History comparison | Closes the comparison. An open find widget, suggestion list, command palette or other editor popup, a selection or extra cursors take the Esc first |
| Esc                     | The History panel, with no comparison open                                                                      | Closes the panel                                                                                                                                    |
| Esc                     | The full screen editor, outside the comparison                                                                  | Leaves full screen                                                                                                                                  |

### API

Two read only endpoints list a variation's versions and return one version
with its code. See [variant code history](/developer/rest-api#variant-code-history)
in the REST API reference. No endpoint writes versions: they are stored only
as a side effect of the saves above.

## Troubleshooting

### Why does a version say Recovered?

Storing a version happens after the save itself, and if it fails the save is
kept anyway. Your code was saved, but the history missed that version. The
next time ABTestly writes to the history for that experiment, it finds that
the saved code differs from the newest version and stores the missing code as
**Recovered**, dated when that code was saved. Until then, History shows
[Current (not yet in history)](#current-not-yet-in-history).

A Recovered version has no author recorded, because ABTestly cannot know who
saved that code. Its author shows as **Author not recorded**. To find who
saved it, look for the save in the [Activity log](/team/activity-log).

### Why does Since launch say History starts on a date?

The experiment launched before the oldest stored version. That happens with
experiments that existed before code history: their first version is a
**Baseline** dated at the variation's last save. If the variation was saved
after launch, the code that actually ran at launch was never stored, so
History compares the oldest version it has and tells you where its record
starts. The same applies to **Since last reset** when the last reset came
before the oldest version. If the variation had not been saved since launch,
the Baseline is the launch code and no note appears.

### Why is Review changes greyed out right after I saved?

Once the save goes through, your draft is the saved code, so there is
nothing left to compare. Open **History** and click **Previous save** to see
what that save changed.

### Two versions show the same code. Why are they separate versions?

Look under the **Comparing revision** heading. When the libraries differ, a
different library or the same libraries in a new order, a line there names
the difference, for example **Libraries: same libraries in a new load
order**. Whitespace changes show in the comparison too, so check the
highlighted lines as well. Two versions that are not next to each other can
also hold the same code, for example when a later save put back older code.

### Why does the author say Former member?

The person who saved that version no longer has an account. The version and
its code are kept. A **Recovered** version shows **Author not recorded**
instead, and a **Baseline** version shows **Code before history began**.

### Why can't I find History on a variation?

History sits above a variation's code, so it is offered wherever the code
is. The Original shows its code section only when it has code, and variations
in a [Split URL test](/build/redirect-tests) carry a redirect instead of code,
so neither offers History. A variation that was removed from the experiment
has no row to open.

### Can I get back code from before code history existed?

No. The **Baseline** is the oldest version History has. For saves in the last
6 months, the [Activity log](/team/activity-log#code-changes) may still hold
the before and after.

### Does restoring change anything on my site?

No. Restoring only loads the version into your editor. Your site changes when
you save, and on a running experiment that save republishes it.

## Related

<CardGroup cols={2}>
  <Card title="Review changes" href="/build/review-changes">
    Compare unsaved edits with the saved code before you save.
  </Card>

  <Card title="Autosave and drafts" href="/build/autosave">
    The local draft that recovery and restore both work with.
  </Card>

  <Card title="Editing a running test" href="/results/editing-a-running-test">
    What happens to your data when you change code on a test that is running.
  </Card>

  <Card title="Activity log" href="/team/activity-log">
    Who changed what across the workspace, for six months.
  </Card>
</CardGroup>
