I need an alternative to using <script src for external JS files

Discussion in 'JavaScript' started by skullcane, Nov 10, 2011.

  1. #1
    Hey guys.


    So right now I'm able to execute javascript code on my website without the use of <script> tags. Example: <body onload=alert("cool");></body>


    What I want to be able to do is insert an external javascript file located at another website using JavaScript code (not script tags). How can this be done?


    Thanks
     
    skullcane, Nov 10, 2011 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You could use Server Side Includes or PHP's include() function to embed the external JavaScript into your pages, but, of course, you'd still have to surround the code with <script> tags in order for it to work. If you were trying to conceal the fact that you are using an external JavaScript file from your users, it would do the trick, although the other site would still show your usage in their server logs. On the whole, it seems like more effort than it would be worth.
     
    rainborick, Nov 11, 2011 IP