--- title: Sandbox summary: SCSS, JS & HTML web Sandbox publishedAt: 1692935425000 updatedAt: 1717543018000 --- For fun, I thought I'd look into making my own online editor for `HTML`, `JS` and `SCSS`. I ended up with a page I'm relatively happy with and I learnt a bit along the way. The page features SCSS compilation as well as saving to the URL. [You can check the page out here](/sandbox.html) By default – Javascript is disabled and not evaluated until you enable it. This can be seen in [this demo](/sandbox.html?data=eJxNUl1v2zAM%2FCusig0t0LjZ2%2BCmAbpgwB72BWQPLeo%2ByBYdq1VEQaSTeUX%2B%2ByR7WfMmHU93R1KvqpOtU6VaGLuDxmnm20rtLO4rtax8JYuw%2FBmRGSp15xysyGClQAgyB557FmgStrgOR%2FoD9dBoD9KhTzXndGDMN%2Fjy69tXeA%2Fr1XoNeyvdCAoFiHbTCdxD3YuQ5xOxHyGJDNRHMLhDRwFj0vRMDs9g0MPZxF1cp%2FhLdaUa5tRMMYZ7zRo1%2FZ6x%2FWP9poSaosE4S9DNWNLNyyZS700J523bjmCHOUsJH%2BbzdyMQtDHj649hfJahSbqSlrzMWr21biiBtecZY7ST0GHiFrVOY%2FvHD8RWLPkSdJ1a6AVvpsLeGumy6eQhpzn%2BQ6d5I5ojOjUVtbE9n%2BRO%2Foc0kOc8j8eiKC4MNf0WvRQblM8O85E%2FDau88u96ixfHtV9ePj3OnwqWwWHx5rkiRxFu0z8I1r9USh3%2BAk%2BJyeg%3D) which will only set the background to pink once you enable JS and interact with the editor. Be warned though, once Javascript has been enabled – if a script loops endlessly you may lock up your browser. Don't run anything here you wouldn't run yourself in the console! Saving to URL was an unexpected issue for this project, Most URLs can only be about 2000 characters long[^1]! This was overcome by using a GZIP implementation to first compress the data before inserting it into the URL parameter. This obviously doesn't solve every use case, however the editor will now warn you when trying to load a code snippet that is too long from the URL. I used the following packages to help with development: - [sass](https://www.npmjs.com/package/sass) - Compile SCSS into CSS - [pako](https://github.com/nodeca/pako) - GZip Implementation - [prism](https://prismjs.com/) - Web native syntax highlighting Some of the main hurdles I encountered while working on this project were: - There are no children inside a `