I've put the following _mydeck.js file in the collection.media/ folder:
var count = ++count || 1
if (count == 1) {
var niverennou = niverennou || [
"zero", "unan", "daou", "tri", "pevar",
"pemp", "c'hwec'h", "seizh", "eizh", "nav", "dek"
];
}
Then, in the question (Front) of a card of my deck, I have:
<script src="_mydeck.js"></script>
{{Kentel}}
<div id="kentel"></div>
<div id="debug">0</div>
<script>
// Javascript File Loading Count
document.getElementById("debug").innerHTML = count;
// Lessons number in letters
document.getElementById("kentel").innerHTML = niverennou[{{Kentel}}];
</script>
When a first card's question is displayed, the debug counter shows 0 meaning that the javascript file is not yet loaded. Then when showing the answer and further cards, the debug counter is incremented and the kentel variable is properly set.
How can I have the javascript file taken into account as soon as the first card's question is loaded ?