p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript (http://p2p.wrox.com/forumdisplay.php?f=85)
-   -   Thoughts on Dynamically assigning external js file (http://p2p.wrox.com/showthread.php?t=14578)

fs22 June 23rd, 2004 12:31 PM

Thoughts on Dynamically assigning external js file
 
FOlks,

I have a page that assigns an external js file with code like the follow (is a sample):

    switch (optwizsel)
    {
        case "YYP":
            window.document.write("<scr" + "ipt language='JavaScript' src='setup/alerts/alertwizard1.js'></scr" + "ipt>");
        break;

So, basically I test several items and attach the js file based upon the test. This job has the potential for doing a lot of tests to attach several extenal js files. Here is my question...is it more efficient to attach one js file and that js file does the testing to attach the appropriate js file and is that even possible?

My code works fine now, but I am concerned about size and speed for the future.

Clay Hess

Snib June 23rd, 2004 02:12 PM

Once again, this would probably be more efficient on the server-side, but if you have to do it on the client-side, neither way would really be more efficient. JavaScript is known for executing instantly. A simple inclusion of an external script takes less than a second.

Yes, I believe it is possible to attach external files within an external file. Just use the same code you would always use. Also, attaching from an external file would probably make your overall code look cleaner.

HTH,

Snib

<><


All times are GMT -4. The time now is 07:53 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.