2

What are the performance hit or implications, if any, of:

  1. If I have multiple <script> tags on one .aspx page?

  2. Declaring variables in <script> tags of a .aspx page and calling these variables from an external .js file?

2 Answers 2

5

Multiple <script> tags containing in-line javascript will not affect performance. Multiple <script> tags that load external javascript files will of course result in multiple requests; in this case it's better for performance to combine the external files into a single file.

Declaring variables within the page and referencing them outside is fine, although of course you need the declarations to be before the tags that load the external file. This is a common pattern for situations where you're getting the value for a javascript variable from server-side code.

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

Comments

1

There is really no inherent performance hit in running JavaScript on your page. Now, if it's a lot of really slow JavaScript, that's another story entirely. But the nature of just having it there isn't going to hurt anything.

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.