471,887 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Disadvantage of including JavaScript files within a JavaScript file?

What's the possible disadvantage of including JavaScript files within
a JavaScript file? Why I needed it? For the sake of easy management,
perhaps? Any load speed disadvantage? Example below:

document.write('<script type="text/javascript" src="'+libraryName+'"><
\/script>');
Jul 7 '08 #1
1 1712
There is one possible disadvantage with including files externally
concerning debugging. This only really concerns Internet explorer.

If you have an error in one of your scripts, you'll get a line number,
but the number will not correspond to the correct line unless all the
JS code is inline with the HTML.

To explain this, if you have the following code...

<html>
<head>
<script src='somescript.js'></script>
</head>
<body>
....HTML
</body>
</html>

and somescript.js looks like

-----------
alert("ok");
allertt("not ok");
-----------

You would normall get an error on line 2, but as the script is
included on line 3, the error message will tell you its on line 5, and
when multiple scripts are included it can be a nightmare to find the
line.

-------
Jul 8 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Catherine Lynn Smith | last post: by
4 posts views Thread by Ralf Koms | last post: by
9 posts views Thread by Trenqo 0 | last post: by
3 posts views Thread by Joseph Ferris | last post: by
5 posts views Thread by Chris Ashley | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.