P5js in an epub3 on kobo ereader?


I’m starting playing with kobo ereader and epub 3 format.
I’ts xhtml5, on kobo ereader with the kepub.epub js are running.
I’m able to run basic script and attempt to use P5js, to use it canvas abilities…
I’ve tried to import lib

<script src="../Misc/p5.js" type="text/javascript"></script>
<script src="../Misc/p5.dom.js" type="text/javascript"></script>

and code directly in the xhtml page in the script area

<script type="text/javascript">
	function setup() {
	function draw() {
    	ellipse(50, 50, 80, 80);

if i try the page in a browser it works!
but in the epub, nothing happening!.
Any idea?
canvas still working in kobo ereader with kepub extension

is there somebody here who has try? and want to share knowledges?

thanks very much


1 Like

I’ve try a simple exemple on canvas with js, and it works on the kobo.

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");

I’m not an epub3 expert by any means, but this doesn’t look right – I think you javascript resources need to be stored in a specific place and then listed in a manifest, maybe?

So be careful not to leave out the declaration highlighted in bold above. Also, any and all resources referenced in your HTML content need to be listed in the OPF <manifest> . Here’s a sample manifest <item> for an external JavaScript file

Perhaps see also:

This answer, which is about iBooks not kobo but similar:


oh f…
i’m sorry, i did not see your answer.
i use Sigil for making epub, it realise all the statements in the opf…
thanks for your time…
Kobo have an old js interpreter. it does not like es6 js style…

love the idea to code on a kobo ereader, but it’s to hard to code in backward style… :wink: