SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Combine JS to an External file.

    Hello.
    i just to be point okey...^^
    how to combine JS to an external file in order reducing http request.
    i have this script at my head section.

    {* JavaScript libraries *}
    {if $load_Javascript}
    <script type="text/javascript" src="www.example.com/javascripts/jquery.min.js"></script>
    <script src="www.example.com/javascripts/ajax.js" type="text/javascript"></script>
    <script type="text/javascript" src="www.example.com/javascripts/jquery/jquery-ui.custom.min.js"></script>
    <script type="text/javascript" src="www.example.com/javascripts/jquery.validates.js"></script>


    so i try add like this.
    i copy this following code to notepad like this.

    {* JavaScript libraries *}
    {if $load_Javascript}
    **** <script type="text/javascript" src="www.example.com/javascripts/jquery.min.js"></script>
    <script src="www.example.com/javascripts/ajax.js" type="text/javascript"></script>
    <script type="text/javascript" src="www.example.com/javascripts/jquery/jquery-ui.custom.min.js"></script>
    <script type="text/javascript" src="www.example.com/javascripts/jquery.validates.js"></script>
    ***** and name by example.js

    and put new code at head section <script type="text/javascript" src="www.example.com/javascripts/example.js"></script>
    it's already good?? thanks

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Ellysdirectory View Post
    how to combine JS to an external file in order reducing http request.
    You need to take the text contents of the script files and combine them all in to one long script.
    This can commonly be done by automated tools that do much of the tough work for you, such as Google's minify
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •