Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You've got quite a bit of confusion here.</p> <blockquote> <p><strong>1.</strong> <em>Which is faster, parseInt(el.style.width) or el.offsetWidth?</em></p> </blockquote> <ul> <li><p><code>el.style.width</code> gives you the width set by javascript or style attribute in the markup. </p></li> <li><p><code>offsetWidth</code> gives you the current width of the element (including borders).</p></li> </ul> <blockquote> <p><strong>2.</strong> <em>Should I write <code>parseInt(el.offsetWidth)</code>?</em></p> </blockquote> <p>No, <code>offsetWidth</code> returns a number. But you should specify the radix whenever you use <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt" rel="nofollow"><code>parseInt</code></a>!</p> <blockquote> <p><strong>3.</strong> <em>Which is faster, <code>getElementById()</code> or <code>childNodes[]?</code></em></p> </blockquote> <p>If you got the parent use the <code>childNodes</code>. If you got the id, you can use byId. Performance will depend on the browser (<a href="http://jsperf.com/childnodes-getbyid" rel="nofollow">test</a>).</p> <blockquote> <p><strong>4.</strong> <em>Which is faster, <code>new Image()</code> or <code>appendChild('img')</code>?</em></p> </blockquote> <p>If you want to force the browser to download a resource, use <code>new Image()</code>. If you want to add an image to the layout use <code>appendChild(IMAGE_ELEMENT)</code></p> <blockquote> <p><strong>5.</strong> <em>Give me please a link to a splendid Javascript PERFORMANCE guide</em></p> </blockquote> <p>I rather leave you with this link: <a href="http://jsperf.com/" rel="nofollow">http://jsperf.com/</a>, and let you do A/B testing. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload