Okay so I may still not be following everything completely, but couldn’t you add the attribute you need to the save function as a data attribute or class?
I’m also curious what happens when you use the CodeEditor component in the save method (I haven’t experimented with it yet).
Not sure if it relates, but blocks were not designed to be interactive on the frontend. So if you want a block to have JS run on the frontend you do need to load it separately in a script loaded to the frontend like you’re describing.
Hope this helps a bit? Let me know how the experimentation goes!