You can read/write an HTML5 data attribute in just the same way as any other type of attribute - they are already used throughout bedrock on different pages. See the jQuery `data()` method: http://api.jquery.com/jQuery.data/

The big reason to avoid small bits of inline JS like this is for sane debugging, and global objects should be avoided whenever possible.