Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify disabling right click context menu by disabling it in JS or with return!1 in HTML #99

Open
burntcustard opened this issue Sep 21, 2021 · 2 comments

Comments

@burntcustard
Copy link
Owner

burntcustard commented Sep 21, 2021

Minified HTML demo https://codepen.io/burntcustard/pen/BaZVoqX

Discussion: https://js13kgames.slack.com/archives/C1EHVV2DN/p1632204464031100

Should maybe put in as a build step, which replaces all occurrences of "return false" in the HTML with return!1

@rushabhkoradia
Copy link

document.addEventListener('contextmenu', event => event.preventDefault());

@burntcustard burntcustard changed the title Try disabling right click context menu in JS instead of HTML to save a few bytes Minify disabling right click context menu by disabling it in JS or with return!1 in HTML Sep 21, 2021
@burntcustard
Copy link
Owner Author

document.addEventListener('contextmenu', event => event.preventDefault());

Yep that would work for putting it in the JS - but it seems we can also return false, or even return !1 instead of preventing-default.

I'll have a go later and see what actually saves the most bytes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants