Self Invoking Function Speed

I came away with a handy Javascript speed tip from an interesting post on Stack Overflow yesterday. Commonly you will see the following syntax for a self-invoking function in Javascript:

As it turns out, you can replace the function wrapping parenthesis with a leading bang:

Results from a jsperf.com benchmark test show that this is 9% faster than using parenthesis. Awesome!

One comment on “Self Invoking Function Speed

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>