SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Externalise Scripts in <head>

    Hi,

    I have the following two scripts in the head section of my site. I believe that they are somehow making the site a bit unresponsive. How would I externalise them and how would I call them..

    <script type="text/javascript">
    $(document).bind("mobileinit", function () {
    $.mobile.ajaxLinksEnabled = false;
    });
    </script>


    <script language="javascript" type="text/javascript">
    window.onload = function() {
    setTimeout(function(){window.scrollTo(0, 1);}, 100);
    }

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by HalfMan View Post
    How would I externalise them and how would I call them
    You would put the script code in a separate file, perhaps called script.js

    Code javascript:
    $(document).bind("mobileinit", function () {
        $.mobile.ajaxLinksEnabled = false;
    });
     
    window.onload = function() {
        setTimeout(function(){window.scrollTo(0, 1);}, 100);
    }

    and call it with:

    Code html4strict:
    <script src="script.js"></script>
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


Tags for this Thread

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
  •