<script> document.getElementById("sketch").addEventListener("load", function() { var marvin = getMarvin("sketch"); if(marvin != null) { marvin.onReady(function() { if(typeof marvin.sketch != 'undefined') { marvin.sketch.addButton("custom","examples/images/custom-icon.png","W", function() { alert('The custom button has been pushed.'); }); } }); } }); <script>