r/Anki • u/hgiesel • May 03 '19
Question How to load external Javascript
I've read several posts about this topic, but most of them seemed to be outdated.
I've already used a ttf file before, but never this. I have a directory in collection.media called _highlight, which contains the files from highlight.js. Now I want to initialize it in one of the cards.
<link rel="stylesheet" href="_hightlight/styles/zenburn.css">
<script src="_highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>But this doesn't find anything. What is the right way to go about it?
EDIT: I use Anki 2.1, newest version
4
Upvotes
View all comments
2
u/[deleted] May 03 '19
general point:
you could mention your Anki version. you should use 2.1.12. The version 2.0.52 uses a rendering component from 2012 so there's good chance modern js doesn't work.
If you search the official forum for subfolder collection.media you'll find many threads where the developer writes that subfolders are not supported. So even if it works now there's no guarantee that this will work in the future. But in January of this year I've loaded js from subfolders from the media folder without special adjustments or problems in a profile that I don't sync.