Safest Way to Get the JavaScript Source

Different browsers over the years have treated JavaScript rather differently, especially when it comes to seeing or copying JavaScript code. The following steps come out of many experiences of not being able to get all the JavaScript code in a page that one loaded, even though it seemed like it was all there.

The steps below are a good practice to follow, even if most contemporary browsers do not hide or over-write JavaScript code when a page is loaded. However, the steps below are not sufficient if part or all of the JavaScript in a page is located in an external .js file.

Not doing the following procedure may mean you miss part of the scripting that makes the page work.

How to get all of the source Javascript you want to use

This is not guaranteed to work in every case (for example: with externally linked .js files used by JavaScript frameworks), but for page-specific code in the head of the HTML page, it is usually sufficient.

If you want a working copy of a page that has Javascript in it, do the following:
  1. find or make a link to that Javascript page

  2. Command+Click on the link (Mac) OR right click on the link (pc) OR hold down on the link
    Then wait for a menu to pop up, and choose Save this Link As (if in Firefox, etc) or Download this Link to Disk, or whatever option is most similar...

  3. In the window that opens up, choose where you want to save the file
    You may need to make sure the Format is set to HTML or HTML Only or Source or All Files, and THEN name the page something appropriate and save it.

  4. I recommend that you keep an original, unchanged version of this document in case things stop working when you create you own documents using that Javascript. Therefore, it is a good idea to immediately make a copy of the downloaded JavaScript file right after you have finished saving it to disk, and to only try to work on copies of the original JavaScript.
Again, not following the above procedure may mean you miss part of the scripting that makes the page work.