# P5js in an epub3 on kobo ereader?

**URL:** <https://discourse.processing.org/t/p5js-in-an-epub3-on-kobo-ereader/9266>\
**Category:** Coding Questions\
**Created:** [March 13, 2019, 2:25pm UTC](https://discourse.processing.org/t/p5js-in-an-epub3-on-kobo-ereader/9266 "2019-03-13T14:25:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbbp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mrbbp/32/15313_2.png) [@mrbbp](https://discourse.processing.org/u/mrbbp)\
**Post date:** [March 13, 2019, 2:25pm UTC](https://discourse.processing.org/t/p5js-in-an-epub3-on-kobo-ereader/9266/1 "2019-03-13T14:25:45Z")

</div>

Hello,

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

```auto
<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

```auto
<script type="text/javascript">
//<![CDATA[
	function setup() {
    	createCanvas(400,400);
	}
	function draw() {
    	ellipse(50, 50, 80, 80);
	}
//]]>
</script>

```

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

éric

---

<div class="post-metadata">

**Author:** ![mrbbp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mrbbp/32/15313_2.png) [@mrbbp](https://discourse.processing.org/u/mrbbp)\
**Post date:** [March 13, 2019, 2:33pm UTC](https://discourse.processing.org/t/p5js-in-an-epub3-on-kobo-ereader/9266/2 "2019-03-13T14:33:04Z")

</div>

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

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

<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
</script>
</body>

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 16, 2019, 6:50am UTC](https://discourse.processing.org/t/p5js-in-an-epub3-on-kobo-ereader/9266/3 "2019-03-16T06:50:44Z")

</div>

> [@mrbbp](#):
>
> …/Misc/p5.js

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?

> **[HTML5 for Publishers](https://www.oreilly.com/library/view/html5-for-publishers/9781449320065/ch06.html)**
>
> Chapter 6. Embedding HTML5 in EPUB Thus far, we’ve built several HTML5 applications well suited to be embeded in ebooks. Now we’ll take a look at how to structure and … - Selection from HTML5 for Publishers \[Book\]

> 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:

- [Anatomy of an EPUB 3 file – EDRLab](https://www.edrlab.org/epub/anatomy-of-an-epub-3-file/)
- [https://w3c.github.io/publ-epub-revision/sc/sc-packaging.html](https://w3c.github.io/publ-epub-revision/sc/sc-packaging.html)

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

> <https://stackoverflow.com/questions/23679325/epub-and-javascript>

---

<div class="post-metadata">

**Author:** ![mrbbp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mrbbp/32/15313_2.png) [@mrbbp](https://discourse.processing.org/u/mrbbp)\
**Post date:** [September 27, 2020, 9:06pm UTC](https://discourse.processing.org/t/p5js-in-an-epub3-on-kobo-ereader/9266/4 "2020-09-27T21:06:12Z")

</div>

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… 😉

é.

regards
