SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Are cached javascript .js files parsed?

    Lets say you have a 1000 line javascript file which is linked to an everyday html file. The browser is set, by default, cache the linked javascript file (after downloading and interpreting it).

    But once it's cached and put into a temp directory on the client's computer, is the cached file in an already parsed format? Or something relative? Or is it in the same format as it was on the server-side? This would mean that the .js file is parsed each time the exact same way (as long as the file itself is not changed, deleted, or renewed on the server-side).
    I can't believe I ate the whole thing

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,804
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    JavaScript parses each line as it is run. If you have a loop that is run a million times then it is parsed a million times during the run.
    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="^$">

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the browser just caches the file. The javascript runtime will have to parse and interpret each time.


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
  •