<?php
echo (new w3l\scriptify)->encode('
var owner = "us";
alert("All your base are belong to " + owner);
');
Results:
<script src="scriptify.php?js=dmFyIG93bmVyPSJ1cyI7YWxlcnQoIkFsbCB5b3VyIGJhc2UgYXJlIGJlbG9uZyB0byAiK293bmVyKQ%3D%3D" integrity="sha384-e7SU+5i8b6bk4ck7S4uufgvLeOPVujVWDF4LdCN/H/5IPQVC021203V7dcB+MLFI"></script>
It's also possible to send attributes:
echo (new w3l\scriptify)->encode('
<script async crossorigin="anonymous">
var owner = "us";
alert("All your base are belong to " + owner);
</script>
');
Results:
<script src="scriptify.php?js=dmFyIG93bmVyPSJ1cyI7YWxlcnQoIkFsbCB5b3VyIGJhc2UgYXJlIGJlbG9uZyB0byAiK293bmVyKQ%3D%3D" integrity="sha384-e7SU+5i8b6bk4ck7S4uufgvLeOPVujVWDF4LdCN/H/5IPQVC021203V7dcB+MLFI" async crossorigin="anonymous"></script>
Call w3l\scriptify::decode
to generate the code externally:
var owner="us";alert("All your base are belong to "+owner)
<?php
header("Content-Type: application/javascript");
echo (new w3l\scriptify)->decode($_GET["js"] ?? "");