# Simple Example Javascript Extension

**URL:** <https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368>\
**Category:** Extensions\
**Created:** [July 27, 2020, 7:01pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368 "2020-07-27T19:01:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![iqanansoft](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@iqanansoft](https://staging-discuss.dev.twitch.com/u/iqanansoft)\
**Post date:** [July 27, 2020, 7:01pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368/1 "2020-07-27T19:01:36Z")

</div>

HI!!! I have many problems with the javascript code in an extension, it does not work, any basic example?

for example the typical

event element.onclick  
with  
element.innerHTML = “Hello World”

Another question … how to apply the policy rules, in an extension?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [July 27, 2020, 7:03pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368/2 "2020-07-27T19:03:56Z")

</div>

Heres one I wrote

> **[GitHub - BarryCarlyon/twitch\_profile\_extension: A simple Twitch Extension to...](https://github.com/BarryCarlyon/twitch_profile_extension)**
>
> A simple Twitch Extension to cover the basics of using the JWT and EBS together to get Twitch API information - GitHub - BarryCarlyon/twitch\_profile\_extension: A simple Twitch Extension to cover th...

That give some examples fo

> [@iqanansoft](#):
>
> event element.onclick  
> with  
> element.innerHTML = “Hello World”

> [@iqanansoft](#):
>
> Another question … how to apply the policy rules, in an extension?

What policy rules do you refer to?

---

<div class="post-metadata">

**Author:** ![iqanansoft](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@iqanansoft](https://staging-discuss.dev.twitch.com/u/iqanansoft)\
**Post date:** [July 27, 2020, 8:09pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368/3 "2020-07-27T20:09:45Z")

</div>

> What policy rules do you refer to?

> **[Extensions](https://dev.twitch.tv/docs/extensions/)**
>
> Get started with Twitch Extensions

section “Restrictions on content”

I thought a “manifest” file (json/xml) with permissions was needed

last question

is required that the javascript code is into .js file for it to work …

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [July 27, 2020, 8:10pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368/4 "2020-07-27T20:10:50Z")

</div>

> [@iqanansoft](#):
>
> section “Restrictions on content”
> 
> I thought a “manifest” file (json/xml) with permissions was needed

Nope! The restrictions there just tells you what you can or cannot do.

> [@iqanansoft](#):
>
> is required that the javascript code is into .js file for it to work …

Yes you cannot use inline JS has to be included via a script tag

---

<div class="post-metadata">

**Author:** ![iqanansoft](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@iqanansoft](https://staging-discuss.dev.twitch.com/u/iqanansoft)\
**Post date:** [July 27, 2020, 8:14pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368/5 "2020-07-27T20:14:59Z")

</div>

I don’t know why a simple “onclick” event with “innerhtml” doesn’t work for me inside tags in .html file, I will check the code again …

thanks

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [July 27, 2020, 8:17pm UTC](https://staging-discuss.dev.twitch.com/t/simple-example-javascript-extension/27368/6 "2020-07-27T20:17:09Z")

</div>

Mines here

> <https://github.com/BarryCarlyon/twitch_profile_extension/blob/master/extension/script.js#L27>

Check the console for errors and follow the error (if any shown) back
