Comment ajouter un jeu à votre site web : intégrer HTML5/JS, Unity, ou iframe
Intégrer un jeu sur votre site : méthodes & code
Option 1 : Jeu HTML5 / JavaScript (Auto-hébergé)
Si vous avez un jeu construit avec Phaser, PixiJS, Three.js, ou JS vanilla :
<!DOCTYPE html> <html> <head> <title>Mon Jeu</title> <style>canvas { display:block; margin:auto; background:#111; }</style> </head> <body> <canvas id="gameCanvas" width="800" height="600"></canvas> <script src="game.js"></script> </body> </html>
- Téléversez
game.js+ assets sur votre serveur. - Assurez en-têtes CORS si chargement depuis sous-domaine/CDN.
Option 2 : Build Unity WebGL
- Dans Unity : Fichier → Paramètres build → WebGL → Build.
- Téléversez dossier
Build(contient.js,.wasm,.data,index.html). - Intégrez via iframe ou intégrez le chargeur généré :
<iframe src="/games/monjeuunity/index.html" width="960" height="600" allowfullscreen></iframe>
Option 3 : iframe embarqué depuis portails jeux
Sites comme **CrazyGames, Poki, GameMonetize, GameDistribution** fournissent codes embed :
<iframe src="https://html5.gamedistribution.com/GAME_ID/" width="800" height="600" scrolling="none" frameborder="0"></iframe>
Partage revenus (pub) typiquement 30–50 % pour vous.
Option 4 : Plugins WordPress
- Arcade Games — importe jeux HTML5/Unity.
- Game Monetize / HTML5 Games — embed shortcode.
- MyArcadePlugin — premium, grande bibliothèque.
Vérifications critiques avant lancement
- Testez sur mobile (contrôles tactiles, orientation).
- Vérifiez HTTPS (requis pour gamepad, plein écran, APIs stockage).
- Ajoutez
loading="lazy"aux iframes sous la ligne de flottaison. - Incluez **Content Security Policy** autorisant scripts jeu.
- Créditez développeur / conformité licence.
