• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Reusable Javascript

Creating external JavaScript files will not only save download time with users, but also will make updating a site less painful for you. Instead of keeping common JavaScript used throughout the site within the page, externalize the code to its own file and attach it to the document(s) that need it. Choose File > New, select JavaScript in the Basic Page category, and then click Create. Just add the JavaScript code to the file without the <script> tags. When it comes time to attach 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 button 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. Don’t forget to add a type attribute to the <script> tag if you want to be sure your page uses valid (X)HTML.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint