# Can I use p5.js to create playable ads for Google, Facebook and Unity ads?

**URL:** <https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797>\
**Category:** Project Guidance\
**Created:** [April 23, 2023, 1:05am UTC](https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797 "2023-04-23T01:05:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![salmaan25](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@salmaan25](https://discourse.processing.org/u/salmaan25)\
**Post date:** [April 23, 2023, 1:05am UTC](https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797/1 "2023-04-23T01:05:42Z")

</div>

I am currently working on building a 2D playable ad for a game and p5.js looks like the perfect library for my use case. In order to check whether it would work, I wrote a very simple inline code (using [p5.min.js](https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js)) to test on Facebook playable ad preview tool.

The file works perfectly on the browser (both the desktop and phone browser), however on the tool it fails on the case: `Asset cannot contain any JavaScript redirects.` It also displays some js code on the phone emulator screen of the tool.

What does this mean and how do I fix the issue? I’m sorry but I’m new to web development and javascript so any help would be greatly appreciated. [This](https://jsfiddle.net/salmaan25/4wnrf15e/) is my code in jsfiddle and [this](https://developers.facebook.com/tools/playable-preview/) is the link to the Facebook playable ad preview tool.

[Here’s](https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js) the link to the uncompressed version of p5.js.

---

<div class="post-metadata">

**Author:** ![Tammy](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tammy](https://discourse.processing.org/u/Tammy)\
**Post date:** [April 26, 2023, 2:23am UTC](https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797/2 "2023-04-26T02:23:47Z")

</div>

Don’t think something like this is possible, if ad providers let any javascript run on their ads someone could easily write some malicious code that would then run across all of Facebook/Google. Not a good thing ☹

So I’m sure Facebook/Google would not let arbitrary JavaScript code run on any of their ads.

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [April 28, 2023, 8:20am UTC](https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797/3 "2023-04-28T08:20:41Z")

</div>

It seems you are facing an issue with the Facebook playable ad preview tool. It’s possible that the p5.js library contains some JavaScript code that is being identified as a redirect by Facebook’s tool, which is not allowed for playable ads.

> **[Playable Ad - Facebook App Ads - Documentation - Meta for Developers](https://developers.facebook.com/docs/app-ads/formats/playable-ad/)**
>
> Playable ads are interactive ads that allow mobile app advertisers to offer short previews of their apps before people choose to download it.

You could try to edit the library to comment out the parts that cause the issue, but keep in mind that modifying the library might lead to unexpected behavior or compatibility issues. Since you are new to web development and JavaScript this may not be advisable.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 28, 2023, 9:16am UTC](https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797/4 "2023-04-28T09:16:38Z")

</div>

> [@sableraph](#):
>
> You could try to edit the library to comment out the parts that cause the issue,

They could also use [q5#js](https://q5xjs.Netlify.app), which is a minimalist alternative for [p5\*js](https://p5js.org/reference/). 💡

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [May 1, 2023, 9:33am UTC](https://discourse.processing.org/t/can-i-use-p5-js-to-create-playable-ads-for-google-facebook-and-unity-ads/41797/5 "2023-05-01T09:33:22Z")

</div>

That does sound like a good use case for q5. I’m curious to know if that solves it 👀 Let us know if you try it @salmaan25
