2018.1

Table Of Contents
Other resources
There are also many resources online to help learn about JavaScript performance and coding
mistakes. See for example:
l JavaScript performance
l The 10 most common JavaScript mistakes
l Tips for writing efficient JavaScript.
Note that most resources on the web are about JavaScript in the browser, but the greatest
majority of the tips do, indeed, apply to scripts in general, wherever they are used.
Loading a snippet via a script
Instead of dragging it into the content directly, it is possible, and often very useful, to load a
snippet dynamically. Create a script (see "Writing your own scripts" on page689) and in the
code use the following function:
results.loadhtml(‘snippets/nameofthesnippet.html)
Remote snippets are retrieved in the same way, except that the file extension should be .rhtml
instead of .html.
Note that the name of the snippet must be exactly the same as in the Snippets folder.
This function will insert the snippet in the content at any position where the script's selector is
encountered.
For more examples, see "loadhtml()" on page1067.
Note
Make sure that the file name is exactly the same as the file in the Snippets folder. If the
file name isn’t correct, the snippet will not appear in the template.
Loading part of a snippet
When a snippet contains a part that can be identified by a selector, that selector can be used to
load that part of the snippet into a template.
Page 706