Jsfiddle-like embeds?

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?

1 Like

You can use CodePen:

http://codepen.io/Yakudoo/pen/YXxmYR

Also sketchfab for viewving 3D models:

7 Likes

Great! Will test those out!

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 http://jsfiddle.net/hw9rcLL8/ 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?

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:

Thanks for the reply.

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

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.

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

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

2 Likes