SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,307
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    browsers with javascript off not access <script type="text/javascript" src="...files?

    just came across this in a book for browser javascript on/off detection:

    Code:
    <noscript>
       <img src="monitor.php?scriptoff=true" />
    </noscript>
    just wondering if browsers when js is off will ever access any

    <script type="text/javascript" src="file.js"></script>

    files? i mean wouldn't it be better not to bother with the noscript thing and just be aware of if file.js is accessed? or do some browsers access the file.js even when js is off?

    thanks

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    How would being aware of file.js being requested be enough to replace noscript? You don't have that information until after the page has loaded, so it's too late to act on it.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    There will rarely be a situation where you need to know whether JavaScript is on or off. Generally you also need to know whether the version of JavaScript that is running also supports the commands you are trying to use.

    Most browsers that either don't have JavaScript or have it turned off will ignore external JavaScript files which is one of the reasons for not cluttering the HTML by embedding JavaScript in it.

    Also <noscript> is a block level element which can only go in the body of the page which means that any test there will often be too late when a lot of the time all the javaScript is in the head of the page.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,307
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    > How would being aware of file.js being requested be enough to replace noscript? You don't have that information until after the page has loaded, so it's too late to act on it.

    it'd be enough to replace the particular noscript thing from the book in my first post because its goal is to communicate back to the server if js is on or not. the alternative i've mentioned, if browsers with js off reliably don't access js files, would achieve the same thing while being more efficient as it avoids yet another http request (and the example is from the o'reilly 'website optimization' book which talks about minimising http requests a lot).

    right, thanks for the info. i suppose it does have limited value (regardless of which method). was just a thought. i don't actually need/want to do this at the moment, was just mulling it over.

    thanks.


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
  •