Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Chrome 85
Windows
Desktop
4 years ago
Test name Executions per second
Creation with src 33887.0 Ops/sec
Creation without src 605959.1 Ops/sec
Clone with src 36223.2 Ops/sec
Clone without src 868090.3 Ops/sec
Script Preparation code:
x
 
function makeImage( src ) {
  var img = document.createElement( 'img' );
  img.className='nail';
  if ( src ) {
    img.src='data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
  }
  return img;
}
withSrc = makeImage( true );
withoutSrc = makeImage( false );
Tests:
  • Creation with src

     
    makeImage( true );
  • Creation without src

     
    makeImage( false );
  • Clone with src

     
    withSrc.cloneNode();
  • Clone without src

     
    withoutSrc.cloneNode();