Jsfiddle-like embeds?


(Luis Fraguada) #1

Hello! Just getting started with our community at https://discourse.threejs.org! I wanted to know the right tool to enable us to embed jsfiddles or similar into posts? What I’d essentially like to do is something like is shown in the answer to this stackoverflow question. Here, a working solution is offered right in the post. Is something like this possible?


(Rafael dos Santos Silva) #2

You can use CodePen:

Also sketchfab for viewving 3D models:


Embed javascript code
(Luis Fraguada) #3

Great! Will test those out!


(Luis Fraguada) #4

It is great to have codepen, but our community prefers jsfiddle as most of the examples and issues are tested there. jsfiddle does have embed code, and this is what Edit fiddle - JSFiddle looks like in iframely.

Here is what the embed code looks like:
<iframe width="100%" height="300" src="//jsfiddle.net/hw9rcLL8/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

What would be the way forward to support this on our discourse?


(David Taylor) #5

Someone could make a custom onebox which turns a jsfiddle link into an embed… however any code in the fiddle is run as soon as the embed loads, which can be very risky. See here:


(Luis Fraguada) #6

Thanks for the reply.

Isn’t it the same risk as running the copdepen.io @Falco linked to above?


(David Taylor) #7

Kind of, but the key thing is that the codepen embed is “click to run”, whearas jsfiddle just runs as soon as the page loads.


(Luis Fraguada) #8

Right, but could the custom onebox handle a similar case, where one would need to click a button to load the jsfiddle embed?


(David Taylor) #9

Yes, I guess it could wait for a user click before loading the iframe. Would require more development work but it should be possible.