# Making Construct 3 Games Work in Educational Platforms: A Complete SLS Compatibility Guide
*Published: 3 Sept, 2025*
## The Challenge: Educational Platform Restrictions
When deploying interactive educational content to platforms like Singapore's Student Learning Space (SLS), developers often encounter strict Content Security Policy (CSP) restrictions that can break modern web applications. This is particularly challenging for game engines like Construct 3, which rely on advanced web technologies including Web Workers, blob URLs, and dynamic script execution.
## The Problem We Solved
We had a series of educational interactive games built with Construct 3 that worked perfectly in standard web browsers but failed to load in SLS due to:
- **CSP Violations**: Inline JavaScript execution blocked by security policies
- **Web Worker Restrictions**: Blob URLs for workers not permitted
- **Service Worker Issues**: Registration blocked in restricted environments
- **Dynamic Script Loading**: Runtime script generation flagged as security risks
## Our Solution: A Systematic Approach
### 1. CSP Compliance Strategy
We developed a dual-file approach to handle different deployment scenarios:
**Standard Version (`index.html`)**
- Includes CSP meta tags for self-hosted environments
- Maintains compatibility with modern browsers
- Preserves all Construct 3 features where possible
**SLS-Optimized Version (`index-sls.html`)**
- Removes CSP meta tags (platform sets its own)
- Optimized for educational platform restrictions
- Recommended for SLS deployment
### 2. Inline JavaScript Extraction
**Before:**
```html
<script>
if (location.protocol.substr(0, 4) === "file")
{
alert("Web exports won't work until you upload them...");
}
</script>
```
**After:**
```html
<script src="/ospsg/scripts/init-check.js"></script>
```
All inline JavaScript was extracted to external files to comply with CSP `script-src 'self'` directives.
### 3. Worker Mode Compatibility Layer
We created a compatibility script that forces non-worker mode in restricted environments:
```javascript
// scripts/sls-compatibility.js
async function CheckSupportsWorkerMode(){
console.log("[SLS Compatibility] Worker mode disabled for CSP compliance");
return false;
}
```
This prevents Construct 3 from attempting to use Web Workers with blob URLs, which are typically blocked in educational platforms.
## Implementation Results
### Projects Successfully Fixed:
1. **Character vs Society - Part 1 & 2**
2. **Character vs Nature - Part 1 & 2** (reference implementation)
3. **Character vs Person - Part 1 & 2**
4. **Character vs Self - Part 1 & 2**
### Technical Achievements:
- ✅ **Zero CSP Violations**: All inline scripts externalized
- ✅ **Worker Compatibility**: Graceful fallback to main thread execution
- ✅ **Service Worker Support**: Maintained where permitted
- ✅ **WebGL Rendering**: Full graphics support preserved
- ✅ **Audio Functionality**: Works after user interaction
- ✅ **Educational Platform Ready**: Meets SLS requirements
## File Structure Pattern
Each fixed project follows this consistent structure:
```
project-folder/
├── index.html (with CSP meta tags)
├── index-sls.html (SLS-optimized, no CSP tags)
├── SLS-DEPLOYMENT-GUIDE.md (deployment instructions)
├── scripts/
│ ├── init-check.js (extracted inline script)
│ ├── sls-compatibility.js (worker mode override)
│ └── [other existing scripts]
└── [other project files]
```
## Deployment Strategy
### For SLS Platform:
1. Use `index-sls.html` as the main entry point
2. Rename to `index.html` before zipping
3. Upload the complete project folder
4. Test in SLS environment
### For Other Educational Platforms:
1. Use standard `index.html` with CSP meta tags
2. Adjust CSP directives based on platform requirements
3. Test worker mode compatibility
4. Fall back to SLS-optimized version if needed
## Key Learnings
### 1. CSP is Not One-Size-Fits-All
Different educational platforms implement CSP differently. Having both CSP and non-CSP versions provides maximum compatibility.
### 2. Worker Mode Graceful Degradation
Construct 3 handles worker mode fallback well, but you need to explicitly disable it in restricted environments to prevent errors.
### 3. Platform-Specific Testing is Critical
What works in Chrome doesn't always work in educational platform embedded browsers. Always test in the target environment.
### 4. Documentation is Essential
Each project includes comprehensive deployment guides because platform requirements can change, and different team members may handle deployment.
## Troubleshooting Common Issues
### TinyMCE Errors (False Positives)
```
tinymce.min.js:11 Uncaught TypeError: Cannot read properties of undefined
```
These errors come from the SLS platform's text editor, not your game. They don't affect functionality.
### 403 Errors on Manifest Files
```
GET /appmanifest.json 403 (Forbidden)
```
This is a server configuration issue. The game works without the manifest file.
### Audio Autoplay Restrictions
Modern browsers and educational platforms block audio autoplay. Always require user interaction before playing audio.
## Performance Impact
The compatibility changes have minimal performance impact:
- **Loading Time**: Negligible increase due to additional script files
- **Runtime Performance**: Slight decrease when worker mode is disabled
- **Memory Usage**: No significant change
- **User Experience**: Identical to original implementation
## Future-Proofing Recommendations
1. **Keep Both Versions**: Maintain CSP and non-CSP versions for flexibility
2. **Monitor Platform Changes**: Educational platforms update their security policies regularly
3. **Test Regularly**: Verify compatibility with each platform update
4. **Document Everything**: Maintain clear deployment guides for each project
## Conclusion
By systematically addressing CSP compliance, worker mode compatibility, and platform-specific requirements, we successfully made all six Construct 3 educational games compatible with SLS and similar educational platforms. The dual-file approach provides maximum flexibility while maintaining the full functionality of the original games.
This solution demonstrates that with careful planning and systematic implementation, modern web applications can be adapted to work within the security constraints of educational platforms without sacrificing functionality or user experience.
---
## Technical Specifications
**Platforms Tested:**
- Singapore Student Learning Space (SLS)
- Standard web browsers (Chrome, Firefox, Safari, Edge)
- Mobile browsers (iOS Safari, Android Chrome)
**Technologies Used:**
- Construct 3 Game Engine
- Content Security Policy (CSP)
- Web Workers (with fallback)
- Service Workers
- WebGL/Canvas rendering
- Web Audio API
**Compatibility Requirements Met:**
- CSP `script-src 'self'` compliance
- No inline JavaScript execution
- Blob URL restrictions handled
- Educational platform security policies
- Cross-browser compatibility maintained
---
*This blog post documents the systematic approach to making Construct 3 games compatible with educational platforms. The techniques described can be applied to other web applications facing similar CSP and security restrictions.*
Character vs Nature - Part 1
An Educational Game with CSP-Compliant Hosting for Secure Environments
🎮 Game Overview
Character vs Nature - Part 1 is an educational game developed in Construct 3 that brings storytelling and learning together. Designed for students, the game immerses players in a world where they explore character vs nature conflicts while learning critical thinking, empathy, and problem-solving.
https://vle.learning.moe.edu.sg/moe-library/module/view/7d77cace-3c63-4bec-9533-42e46606da68
Refused to create a worker from 'blob:
https://html.learning.moe.edu.sg/aba6685b-eb78-45b7-86c2-39fad2ff893f' because it violates the following Content Security Policy directive: "child-src 'self'". Note that 'worker-src' was not explicitly set, so 'child-src' is used as a fallback.
|
|
CheckSupportsWorkerMode @ main.js:26Understand this error |
appmanifest.json:1 Failed to load resource: the server responded with a status of 403 ()Understand this error |
Key Features
-
Interactive storytelling enhanced with voice narration
-
Character animations and dynamic visual effects
-
Engaging audio feedback and background music
-
Educational modules that explain conflict types and character growth
-
A progressive learning structure with scaffolded practice exercises
🚨 The Challenge: CSP Compliance
When we first deployed the game to secure platforms like SLS (Student Learning Space) or corporate environments, we encountered a significant issue: Content Security Policy (CSP) restrictions.
The Issues We Found
-
Blob Worker Creation
The original script used URL.createObjectURL(new Blob(...))
, which is blocked in strict CSP environments.
-
Web Worker Dependencies
Construct 3’s worker mode—optimized for performance—relies on workers that CSP restrictions frequently disable.
-
Runtime Failures
The result? Blank screens, "Unexpected end of input" errors, and frustrated users.
🛠️ The Fix: CSP-Compliant Execution
To make the game compatible with strict security environments, we implemented these changes:
1. Disable Worker Mode
Modified the CheckSupportsWorkerMode
function to always return false:
2. Force DOM Mode
The game now runs entirely in DOM mode, removing reliance on Web Workers but preserving all gameplay features.
3. Maintain Performance
Modern browsers are efficient enough that performance remains smooth, even without worker threads.
🔧 Technical Implementation
Key Files Updated
File | Description | Status |
scripts/main.js |
Removed CSP-violating worker code |
✅ Fixed |
scripts/sls-compatibility.js |
Added compatibility layer for static hosting |
✅ New |
scripts/init-check.js |
Override worker detection for extra safety |
✅ New |
index-sls.html |
CSP-safe entry point for hosting |
✅ New |
Script Loading Order
To ensure compatibility, load the scripts in this exact order:
🚀 How to Run the Game
Local Development
Serve the game with a local server for testing:
Then open:
Production Deployment
The game now runs seamlessly on:
-
Static hosting platforms (GitHub Pages, Netlify, Vercel)
-
Educational LMS platforms with strict CSP rules
-
Corporate environments with locked-down browsers
Console Verification
When running correctly, you’ll see:
📁 Project Structure
🧠 Educational Value
This game isn’t just fun—it’s pedagogically grounded. Students learn:
-
Character Development: How characters evolve over time
-
Conflict Analysis: Understanding "Character vs Nature" dynamics
-
Story Structure: Breaking down beginnings, conflicts, and resolutions
-
Critical Thinking: Making decisions and seeing the consequences
-
Interactive Practice: Reinforcement through engaging exercises
🔒 Security Features
-
CSP-Compliant Execution
-
No Inline Scripts for enhanced security
-
Safe Resource Loading with no dynamic code generation
-
HTTPS Ready for modern hosting environments
🤝 Contributing
To contribute or troubleshoot:
-
Check browser console logs for CSP errors
-
Confirm scripts load in the correct order
-
Test across browsers and platforms
-
Document your fixes for community use
📞 Support
If you encounter issues:
-
Inspect browser console for error messages
-
Confirm proper server setup
-
Ensure all assets are accessible via HTTPS
This approach prioritizes compatibility and security while maintaining full gameplay functionality, making Character vs Nature - Part 1 accessible in a wide range of secure learning environments.
# Character vs Nature - Part 1
A Construct 3 educational game with CSP (Content Security Policy) compliance fixes for secure hosting environments.
## 🎮 Game Overview
**Character vs Nature - Part 1** is an interactive educational game built with Construct 3 that teaches about character development and conflict resolution through engaging storytelling and interactive elements.
### Features
- Interactive storytelling with voice narration
- Character animations and visual effects
- Audio feedback and background music
- Educational content about character vs nature conflicts
- Progressive learning structure with practice exercises
## 🚨 Problem Solved: CSP Compliance Issues
### The Original Problem
This Construct 3 game initially failed to run in environments with strict Content Security Policy (CSP) restrictions due to:
1. **Blob Worker Creation**: The `CheckSupportsWorkerMode` function created blob workers using `URL.createObjectURL(new Blob(...))` which violates CSP policies that restrict `blob:` URLs
2. **Web Worker Dependencies**: The game attempted to use Web Workers for performance optimization, but CSP policies often block worker creation
3. **Runtime Errors**: These violations caused the game to fail with "Unexpected end of input" errors and blank screens
### The Solution
We implemented a **CSP-compliant workaround** that:
1. **Disables Worker Mode**: Modified the `CheckSupportsWorkerMode` function to always return `false`
2. **Forces DOM Mode**: The game now runs entirely in DOM mode instead of using Web Workers
3. **Maintains Full Functionality**: All game features work identically, just with a different execution model
4. **Preserves Performance**: Modern browsers handle DOM-based execution efficiently
## 🔧 Technical Implementation
### Key Files Modified
#### `scripts/main.js`
- **Original**: 118,501 bytes with CSP-violating blob worker creation
- **Fixed**: Same size but with CSP-compliant `CheckSupportsWorkerMode` function
- **Change**: Replaced blob worker detection with simple `return false` statement
```javascript
// CSP-Compliant Version
async function CheckSupportsWorkerMode(){
```
### Production Deployment
The game is now compatible with:
- **Static hosting services** (GitHub Pages, Netlify, Vercel)
- **CDN deployments** with strict CSP policies
- **Educational platforms** with security restrictions
- **Corporate environments** with locked-down browsers
### Verification
When running correctly, you should see these console messages:
```
[SLS Compatibility] SLS compatibility mode enabled - workers disabled
[SLS Compatibility] Worker mode disabled for CSP compliance
[SLS Compatibility] RuntimeInterface overridden
Made with Construct, the game and animation creation tool
[C3 runtime] Hosted in DOM, rendering with WebGL 2
```
## 📁 Project Structure
```
├── index.html # Main game entry point (CSP-compliant)
├── index-sls.html # Alternative SLS-compatible entry point
├── style.css # Game styling
├── data.json # Game data and configuration
├── appmanifest.json # PWA manifest
├── sw.js # Service worker
├── scripts/
│ ├── main.js # Main game runtime (CSP-fixed)
│ ├── sls-compatibility.js # CSP compatibility layer
│ ├── init-check.js # Worker detection override
│ ├── c3main.js # Construct 3 main runtime
│ ├── c3runtime.js # Construct 3 runtime engine
│ └── [other runtime files]
├── images/ # Game sprites and graphics
├── media/ # Audio files (VO, SFX, music)
├── icons/ # App icons and loading graphics
└── README.md # This documentation
```
## 🛠️ Troubleshooting
### Common Issues
1. **Black Screen on Load**
- Ensure you're serving via HTTP/HTTPS (not file://)
- Check browser console for CSP violations
- Verify all scripts are loading in correct order
2. **Audio Not Playing**
- Modern browsers require user interaction before audio
- Click anywhere on the game to enable audio
- Check browser audio permissions
3. **Performance Issues**
- DOM mode may be slightly slower than worker mode
- This is normal and acceptable for most use cases
- Consider enabling hardware acceleration in browser
### Browser Compatibility
- ✅ **Chrome/Chromium** 80+
- ✅ **Firefox** 75+
- ✅ **Safari** 13+
- ✅ **Edge** 80+
- ⚠️ **Internet Explorer** - Not supported (Construct 3 limitation)
## 📚 Educational Content
The game covers:
- **Character Development**: Understanding protagonist growth
- **Conflict Types**: Character vs Nature scenarios
- **Story Structure**: Beginning, middle, end progression
- **Critical Thinking**: Decision-making and consequences
- **Interactive Learning**: Hands-on practice exercises
## 🔒 Security Features
- **CSP Compliant**: Works with strict Content Security Policies
- **No Inline Scripts**: All JavaScript is in external files
- **Safe Resource Loading**: No dynamic code generation
- **HTTPS Ready**: Fully compatible with secure hosting
## 📄 License & Credits
- **Game Engine**: Construct 3 by Scirra Ltd.
- **Content**: Educational material by original authors
- **CSP Fixes**: Technical implementation for secure deployment
## 🤝 Contributing
If you encounter CSP-related issues or have improvements:
1. Check the browser console for specific CSP violations
2. Verify the compatibility scripts are loading correctly
3. Test in multiple browsers and hosting environments
4. Document any new compatibility requirements
## 📞 Support
For technical issues related to CSP compliance or deployment:
- Check browser developer tools console
- Verify server configuration allows required MIME types
- Ensure all game assets are accessible via HTTP/HTTPS
---
**Note**: This implementation prioritizes compatibility and security over maximum performance. The game runs identically to the original but uses DOM-based execution instead of Web Workers to ensure CSP compliance.