Combining JavaScript calls via one file

Discussion in 'JavaScript' started by tbarr60, Feb 4, 2010.

  1. #1
    The sites I run have multiple JavaScript files called in from multiple domains. If these JavaScripts come from third parties (like mysite.com, lib.mysite.com, Google, Yahoo, Power Reviews, MyBuys, etc) is there any way to minimize the number of calls?
     
    tbarr60, Feb 4, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are they dynamic or will they never change?
     
    krsix, Feb 4, 2010 IP
  3. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #3
    If they do change, we'd have to cut and past code into the page or into an include file.
     
    tbarr60, Feb 4, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Why not save the .js files locally, then just use a PHP script that combines them into a giant one
     
    krsix, Feb 4, 2010 IP
  5. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #5
    Well, I thought about that but since a lot of it would be like this, I think it would still be making all those calls:

    <script type="text/javascript"
    src="[URL="http://forums.digitalpoint.com/view-source:http://pagead2.googlesyndication.com/pagead/show_ads.js"]http://pagead2.googlesyndication.com/pagead/show_ads.js[/URL]">
    Code (markup):
     
    tbarr60, Feb 4, 2010 IP