# Javascript Compatibility

**URL:** <https://forums.ankiweb.net/t/javascript-compatibility/20623>\
**Category:** Card Design\
**Created:** [June 8, 2022, 11:05am UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623 "2022-06-08T11:05:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjdduarte](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/cjdduarte/32/29286_2.png) [@cjdduarte](https://forums.ankiweb.net/u/cjdduarte)\
**Post date:** [June 8, 2022, 11:05am UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/1 "2022-06-08T11:05:52Z")

</div>

Is there a way to know how many javascript commands are really compatible with Anki?

Is there any technical term to identify this?

I’m asking, because I decided to learn javascript (I love Python) to customize my cards, but not all commands work correctly, requiring some adaptations.

---

<div class="post-metadata">

**Author:** ![BlackBeans](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/blackbeans/32/2283_2.png) [@BlackBeans](https://forums.ankiweb.net/u/BlackBeans)\
**Post date:** [June 8, 2022, 11:58am UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/2 "2022-06-08T11:58:46Z")

</div>

Anki is not the most basic web environment you can get, so if you are learning JS you may be surprised in the result; but this doesn’t mean there is a fundamental incompatibility between JS and Anki.

---

<div class="post-metadata">

**Author:** ![kleinerpirat](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kleinerpirat/32/19863_2.png) [@kleinerpirat](https://forums.ankiweb.net/u/kleinerpirat)\
**Post date:** [June 8, 2022, 12:03pm UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/3 "2022-06-08T12:03:41Z")

</div>

Supported HTML/CSS/JS features depend on the client/OS you’re running Anki on. See for example:

> [@CSS Injector \[Official Support\]](https://forums.ankiweb.net/t/css-injector-official-support/18800/70):
>
> Optional chaining was added in Chromium 80; the macOS Qt5 build uses 5.14 which is Chromium 77. Qt 5.15 introduces some regression, so .14 is better on macOS.

If you know the browser, [https://caniuse.com/](https://caniuse.com/) can serve as a lookup table.

AFAIK there’s no summary of currently used browser engines for all Anki clients. It’s a good idea though, and doesn’t seem that hard to implement.

* * *

> [@BlackBeans](#):
>
> if you are learning JS you may be surprised in the result

Personally, I was positively surprised by Anki’s potiential as a JS learning environment. Working on things you actually make use of tends to be a very efficient way to learn new programming languages.

---

<div class="post-metadata">

**Author:** ![BlackBeans](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/blackbeans/32/2283_2.png) [@BlackBeans](https://forums.ankiweb.net/u/BlackBeans)\
**Post date:** [June 8, 2022, 12:10pm UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/4 "2022-06-08T12:10:54Z")

</div>

IIRC, Anki Desktop (through Qt Webviews) relies on chromium’s engines, that is, Blink (and V8 for the JS engine), AnkiWeb uses whatever you use, AnkiMobile uses safari’s engine (webkit — blink is a fork of webkit, so thy should behave similarly).

---

<div class="post-metadata">

**Author:** ![BlackBeans](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/blackbeans/32/2283_2.png) [@BlackBeans](https://forums.ankiweb.net/u/BlackBeans)\
**Post date:** [June 8, 2022, 12:17pm UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/5 "2022-06-08T12:17:02Z")

</div>

> [@kleinerpirat](#):
>
> Personally, I was positively surprised by Anki’s potiential as a JS learning environment. Working on things you actually make use of tends to be a very efficient way to learn new programming languages.

I agree having a motivating usage can is useful when learning a language, but at the same time coding JS in Anki is probably less practical that writing a “regular” JS script that can be tested in IDE-integrated web environment, for a tighter feedback loop.

---

<div class="post-metadata">

**Author:** ![kleinerpirat](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kleinerpirat/32/19863_2.png) [@kleinerpirat](https://forums.ankiweb.net/u/kleinerpirat)\
**Post date:** [June 8, 2022, 12:17pm UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/6 "2022-06-08T12:17:33Z")

</div>

@cjdduarte also take care to use vanilla JavaScript in your templates.

StackOverflow is riddled with jQuery answers, but nowadays, there’s no real benefit to using this library.

You can easily spot jQuery by its `$`-prefixed functions.

---

<div class="post-metadata">

**Author:** ![cjdduarte](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/cjdduarte/32/29286_2.png) [@cjdduarte](https://forums.ankiweb.net/u/cjdduarte)\
**Post date:** [June 8, 2022, 2:16pm UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/7 "2022-06-08T14:16:53Z")

</div>

I learned new things here that I didn’t know.

The reason to use javascript is not to depend on an addon for simple things.  
More dynamic cards.  
And being able to use on Mobile.

---

<div class="post-metadata">

**Author:** ![BlackBeans](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/blackbeans/32/2283_2.png) [@BlackBeans](https://forums.ankiweb.net/u/BlackBeans)\
**Post date:** [June 8, 2022, 4:12pm UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/8 "2022-06-08T16:12:26Z")

</div>

In general, you should see JS as an “extension” of HTML and CSS, in the sense that it complements these while being at the same level. Anki add-ons, on the other hand, are more though as ways to modify Anki’s behavior.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [May 1, 2023, 7:35am UTC](https://forums.ankiweb.net/t/javascript-compatibility/20623/9 "2023-05-01T07:35:11Z")

</div>

Closed on May 1, 2023, 7:35am UTC


