469,344 Members | 5,642 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

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 1659
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.