Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:10:04+00:00 2026-06-11T10:10:04+00:00

As mentioned in JavaScript, The Good Parts by Douglas Crockford, passing a string to

  • 0

As mentioned in JavaScript, The Good Parts by Douglas Crockford, passing a string to setTimeout or setInterval invokes eval(), and should be avoided:

setTimeout('console.log("this uses eval()");', 100);

With that in mind, does the same thing happen when using inline event handlers, like this?:

<button onclick="console.log('click!');">Click Me</button>

In other words, does using an inline event handler incur extra parsing overhead when the event is fired, or is the parsing done during the initial document load with everything else (e.g. inline script blocks, scripts in the header, etc).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:10:05+00:00Added an answer on June 11, 2026 at 10:10 am

    Yes, figuratively speaking, it does. All javascript in a page is parsed in exactly the same way as code passed to eval(). eval() is to be avoided, mostly because it is slower than plain code, as it requires an additional parse.

    You can verify yourself if the browser has already compiled the handler or reparses it, at least for browsers with decent developer tools (example code uses jQuery, but of course you could rewrite it in plain JS):

    <div id="test" onclick="alert('tested')">Click</div>
    <script>
    console.log(typeof $('#test')[0].onclick);
    console.log($('#test')[0].onclick);
    </script>
    

    In my Chrome test, this logs the following:

    Type of handler: function
    function onclick(event) {
      alert('click')
    } 
    

    It is obvious that the onclick property is a compiled function value. You can also see the extra generated code for the handler, namely the function wrapped around the inline code. You can also set a breakpoint in the handler and observe the stack trace to verify that there is no eval call anywhere in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading Douglas Crockford's JavaScript: The Good Parts , and I came across
Just finished reading Crockford's JavaScript: The Good Parts and I have a question concerning
Here is a working example from Javascript - The Good Parts. function add(x, y){
I was reading JavaScript: The Good Parts and the author mentions that JavaScript is
HI all, Below mentioned javascript code works fine in all browsers including chrome(from second
I was baffled today when someone mentioned on a group that Javascript has evolved
I am using John resig's implementation class mentioned here: http://ejohn.org/blog/simple-javascript-inheritance/ Now I have a
somebody mentioned that the function (in this case a method) below is no good
My friend read an article which mentioned that moving all JavaScript files to the
I was reading an article to disable validators in Javascript using below mentioned reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.