Disadvantage of including JavaScript files within a JavaScript file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vunet

    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="'+libraryN ame+'"><
    \/script>');
  • Laser Lips

    #2
    Re: Disadvantage of including JavaScript files within a JavaScriptfile?

    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.

    -------

    Comment

    Working...