Platypus.js

Experimental JavaScript loader.

Brought to you by Jan Hančič Jan Hančič

platypus.js

Experimental JavaScript loader that loads both CSS and JavaScript from one file resulting in only one request.

The idea is that you hide JavaScript code inside a CSS file. This means that the browser only has to load one file (the CSS) and platypus.js then extracts the JavaScript from the CSS file.

Check out the platypus.js repository to see the code and read instructions on how to use it.

Details

More details can be found in the GitHub repository here and in this blog post.

Demos / proof of concept

I have created several proof of concepts that prove that it is indeed possible to do so. The general idea is to hide JavaScript code inside a CSS file, and extract it after the browser downloads the CSS file. This results in only one request instead of two.

Note that this proof of concepts are just that, so if you wish to see the actual code that is platypus.js go to the GitHub repo and get it from there. This experiments helped me validate the idea and lead to the current code.

You can see the demos in the experiments folder or you can view them live bellow:

Browser support

Tested against all the experiments:

works

doesn't work