1
0
Fork
You've already forked simplewebflashviewer
0
a simple flash viewer used for iframe in other site.
  • JavaScript 61.4%
  • HTML 30.4%
  • CSS 8.2%
Find a file
2026年04月10日 06:51:41 +07:00
src loader.js: raise logLevel to info 2026年03月14日 03:48:08 +07:00
LICENSE license. 2026年03月08日 04:10:44 +07:00
README.md readme: note about serving with compression enabled 2026年04月10日 06:51:41 +07:00

simplewebflashviewer

this is a simple flash viewer used for <iframe> in other site.

using it

whatever is in src/ is a static site, but you will need to download the ruffle's web package, then extract the zip to src/ruffle/. Note that files that ends with .wasm extension must be served with application/wasm mimetype.

to use it in your site, you use a iframe like this:

<iframe
 src="src/"
 width="640"
 height="480"
 allow="fullscreen"
 style="border-color: transparent"
 sandbox="allow-scripts allow-modals allow-popups allow-downloads allow-same-origin"
/>

some of the restrictions has been set under src/loader.js, so several options on the iframe's sandbox attribute should be fine.

you can adjust the width and height to your liking.

say, you're serving this as a static site at https://media.yourdomain.com/flashviewer/

to load an swf, you need to invoke this in your javascript:

<iframeDoc>.src = "https://media.yourdomain.com/flashviewer/index.html#" + swf_url

csp

root domain (the user/frontend)

you will need to ensure that your root domain that loads the iframe has a csp setting of frame-src 'self' data: blob: https://media.yourdomain.com/flashviewer/ https://media.yourdomain.com/media/, assuming that most of the flash are loaded from https://media.yourdomain.com/media/

iframe domain (the simpleWebFlashViewer)

for the csp on the iframe at https://media.yourdomain.com/flashviewer/, because ruffle doesn't understand nonce yet, you will need to ensure that these are set:

  • script-src 'self' 'wasm-unsafe-eval'
  • style-src 'self' 'unsafe-inline'

you might want to also set this:

  • frame-ancestors 'self' https://yourdomain.com assuming you're using this for https://yourdomain.com as the root domain.

optimization

you need to also set the cache-control header to be this:

  • public, max-age=604800, immutable

this ensures that browser do not reload ruffle runtime from server everytime & makes ruffle loading faster, because the ruffle wasm is sized around 13 MB.

your HTTP server must serve this static page with compression enabled to reduce the ruffle wasm from 13 MB all the way to just 4 MB (if done via zstd).