<commit_before># HTML5 custom data attributes jQuery plugin

This plugin simplifies the use of HTML5 custom data attributes in your jQuery code. It adds a function named `.dataAttr()` to the jQuery namespace, which acts as a wrapper for [`jQuery.attr()`](http://api.jquery.com/attr/).

## Example Usage

### HTML

    <p id="foo" data-time="9 AM">…</p>

### jQuery

    // You can perfectly use this:
    $('#foo').attr('data-time'); // '9 AM'
    // But I prefer to do it this way, especially when dealing with a lot of data-*
    $('#foo').dataAttr('time');  // '9 AM'
    // Just like $.attr(), $.dataAttr() can be used as a setter
    $('#foo').dataAttr('time', '3 PM');
    // Computed data-* attribute values are possible as well
    $('p').dataAttr('id', function() {
     return this.id;
    }); // p data-id="foo"

## Useful?

That’s up to you. This plugin isn’t rocket science. Using it won’t save you bytes or anything.

However, it does allow you to write *even more readable code*. Personally, I like to keep custom data attributes separated from other attributes in my code — hence this plugin.
<commit_msg>Hrm, in fact, it *does* save you bytes, when used correctly<commit_after># HTML5 custom data attributes jQuery plugin

This plugin simplifies the use of HTML5 custom data attributes in your jQuery code. It adds a function named `.dataAttr()` to the jQuery namespace, which acts as a wrapper for [`jQuery.attr()`](http://api.jquery.com/attr/).

## Example Usage

### HTML

    <p id="foo" data-time="9 AM">…</p>

### jQuery

    // You can perfectly use this:
    $('#foo').attr('data-time'); // '9 AM'
    // But I prefer to do it this way, especially when dealing with a lot of data-*
    $('#foo').dataAttr('time');  // '9 AM'
    // Just like $.attr(), $.dataAttr() can be used as a setter
    $('#foo').dataAttr('time', '3 PM');
    // Computed data-* attribute values are possible as well
    $('p').dataAttr('id', function() {
     return this.id;
    }); // p data-id="foo"

## Useful?

That’s up to you. This plugin isn’t rocket science.

However, it does allow you to write *even more readable code*. Personally, I like to keep custom data attributes separated from other attributes in my code — hence this plugin.

Since `.dataAttr('foo')` minifies to `.x('foo')`, while `.attr('data-foo')` minifies to `.y('data-foo')`, using this plugin can save you some bytes after minification, especially when dealing with a lot of data attributes in your code.

{'fraction_non_alphanumeric': 0.14383561643835616, 'fraction_numerical': 0.004834810636583401, 'mean_word_length': 3.449820788530466, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '271426', 'n_tokens_mistral': 728, 'n_tokens_neox': 713, 'n_words': 330}