Gist-Embed

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="container">

    <p>Loading a gist</p>
    <code class="gist-embed" data-gist-id="5457595"></code>

    <p>Loading a gist with all line numbers removed</p>
    <code class="gist-embed" data-gist-id="5457605" data-gist-hide-line-numbers="true"></code>

    <p>Loading a gist with footer removed</p>
    <code class="gist-embed" data-gist-id="5457619" data-gist-hide-footer="true"></code>

    <p>Loading a gist with both footer and line numbers removed</p>
    <code class="gist-embed" data-gist-id="5457629" data-gist-hide-footer="true" data-gist-hide-line-numbers="true"></code>

    <p>Loading a gist with multiple files</p>
    <code class="gist-embed" data-gist-id="5457635"></code>

    <p>Loading a single file from a gist (example-file2.html)</p>
    <code class="gist-embed" data-gist-id="5457644" data-gist-file="example-file2.html"></code>

    <p>Loading a single line number from a gist (line 2)</p>
    <code class="gist-embed" data-gist-id="5457662" data-gist-line="2"></code>

    <p>Loading a range of line numbers from a gist (line 2 through 4)</p>
    <code class="gist-embed" data-gist-id="5457652" data-gist-line="2-4"></code>

    <p>Loading a single line and a range of line numbers from a gist (line 1 and line 3 through 4)</p>
    <code class="gist-embed" data-gist-id="5457665" data-gist-line="1,3-4"></code>

    <p>Loading a list of line numbers from a gist (line 2, 3, 4)</p>
    <code class="gist-embed" data-gist-id="5457668" data-gist-line="2,3,4"></code>

    <p>Loading a code element without a gist id data attribute</p>
    <code class="gist-embed">
      This is the content of a code element.  It has no gist id data attribute, so it's not parsed.
    </code>
  </div>

Test runner

Ready to run.

Testing in
TestOps/sec
gist-embed normal

(function($) {

  $(function() {
    // find all code elements containing "data-gist-id" attribute.
    $('code[data-gist-id]').each(function() {
      console.log('test');
    });
  });

})(jQuery);
ready
gist-embed no tag

(function($) {

  $(function() {
    // find all code elements containing "data-gist-id" attribute.
    $('[data-gist-id]').each(function() {
      console.log('test');
    });
  });

})(jQuery);
ready
using a class

(function($) {

  $(function() {
    // find all code elements containing "data-gist-id" attribute.
    $('.gist-embed').each(function() {
      console.log('test');
    });
  });

})(jQuery);
ready
legacy and class support

(function($) {

  $(function() {
    // find all code elements containing "data-gist-id" attribute.
    $('[data-gist-id], .gist-embed').each(function() {
      console.log('test');
    });
  });

})(jQuery);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.