Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe Dreamweaver

This chapter is from the book

REUSABLE JAVASCRIPT

Whenever you have JavaScript code that is common to more than one page, you should externalize the code to its own file and link it to the document(s) that need it. A blank file with the script added to it minus the <script> tags and saved with the .js file extension is all you need. When it comes time to link the external JavaScript file to a document, go to the Scripts category of the Assets panel. Clicking the filename will reveal the file's code inside the preview area. You can either drag the file by its name into the document or click the Insert icon in the lower left of the Assets panel. The <script> tag is added to the document with the proper src attribute that points to the JavaScript file. You should add a type attribute to the <script> tag if you want to be sure your page uses valid (X)HTML.

Figure7.23Figure 7.23

  • + Share This
  • 🔖 Save To Your Account