What are lesser known ways of executing Javascript on sites

So we all know regular ways of calling and executing Javascript on pages, but I was just reading about a hack that hides itself by using the onerror attribute/event of the <img> tag.

I was curious, what other lesser known ways are there to execute JS code people know of.

7 comments · 50% upvoted · other discussions

comments

SubjectHealthy2409

You can use HAM radio waves with no internet connection to send a small JavaScript code to a bitcoin.org owned satellite in space to make a transaction on the BTC blockchain, does this count xd

DM_ME_UR_OPINIONS

That's how I host my portfolio site

Hedge101

Do I hear XSS?

TheRNGuy

Those don't have to be user input.

[deleted]

There's not that many ways beyond other event handlers tbf. One that is interesting is you can load scripts straight from an svg. Lots of interesting ways to bypass filters:

https://cheatsheetseries.owasp.org/cheatsheets/XSS_Filter_Evasion_Cheat_Sheet.html

hyrumwhite

Bookmarklets are a fun way to execute JS

Extension_Anybody150

One lesser-known method is using the onerror event with a <script> tag. By setting an invalid src in the <script> tag, you can trigger JavaScript execution when the error happens. It's a sneaky way to execute code without relying on the typical script loading methods.