JavaScript widget

Use JavaScript widget to embed JavaScript code in your page. JavaScript is used to enhance the functionality of your website. For example, you can use JavaScript to validate user input.

To add a JavaScript code to your page, perform the following:

  1. Drag the JavaScript widget on the page and click Edit button in the upper-right corner of the widget.
    The JavaScript window appears.

    NOTE: If you add JavaScript widget in a page template the JavaScript is applied to all the pages that use this template. If you add it on one particular page, the JavaScript is applied only to this page.

  2. Add the JavaScript code in one of the following ways:
    • If the JavaScript file (files with .js extension) you want to apply is already uploaded, on Link to a JavaScript file (.js) tab, in URL input field, enter the URL of an already uploaded JavaScript file.
      Click Select…button, browse the uploaded files to select the JavaScript file you want to apply, and click Done.
    • If you want to add custom JavaScript code, on Write JavaScript tab, enter the JavaScript code in the input field.
  3. In Where to include in HTML? radio button, select one of the following.
    Select one of the following:
    • In the head tag
      The JavaScript is executed immediately when a page starts to load.
    • Where the widget is dropped
      The JavaScript is executed when the widget is being loaded.
    • Before the closing body tag
      The JavaScript is executed at the end of the page’s loading process.
      For example, this option is often used to embed page tracking code, such as Google Analytics, because if this code is executed, it means that the user has not closed the page before the page has been fully loaded.
  4. When you are finished, click Save.
    The JavaScript window closes and the system embeds the link to the JavaScript file or the code you have written where you have specified in Where to include in HTML radio button.

Additional resources

ARTICLES

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?