1

Does inline Javascript code like this below:

<div onclick='javascript:some_function();'></div>

grow up web page's loading time in any way?

1 Answer 1

2

Yes, it does.

The browser must fire up a separate Javascript parser for each attribute.

It is more efficient to bind the events to functions using attachEvent / addEventHandler, or, more easily, jQuery.


On an unrelated note, you shouldn't use javascript: in an event attribute (aside from the fact that you shouldn't use event attributes at all). It's just an unused label.
In href attributes, the javascript: protocol allows you to create a URI that executes Javascript. However, event attributes take a string of Javascript code, not a URI.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.