Identifying and reducing synchronous AJAX calls generated by client scripts DescriptionLoading a form, such as an incident, takes too long or freezes before any interaction is possible.The Client Transaction Timing widget or log indicates a high amount of browser time for a particular form transaction. Note: To call a business rule from a client script, use GlideAjax. The GlideAjax class allows the execution of server-side code from the client.CauseUse of GlideRecord invocations in onLoad and onChange client scripts.Use of getReference invocations in onLoad and onChange client scripts.ResolutionClient scripts add functionality to the form's user interface and can retrieve data from the server to populate fields or inform logic that affects the user's interactivity with the form. While there is a variety of methods for retrieving data from the server after the initial page request, some of these methods employ synchronous retrieval. This pauses the interactivity with the browser window until the data is retrieved and the script is executed. Making multiple round-trip requests for data after a form has loaded can pause a form for an extended period of time. To identify synchronous AJAX calls that occur when loading a form: A browser with debugging capability is required for this sequence. All modern browsers such as Chrome, Firefox, Safari, and recent versions of Edge have similar utilities. In the ServiceNow instance, locate the record link for the slow form.Open your browser's Developer tools and enable the following settings: Enable the Net panel.As the content type, select XHR. Click the Clear button, then click the link to the form.In the developer tools frame, observe whether any entries appear with URL values of POST xmlhttp.do.Expand each xmlhttp.do request and examine the data listed in the Post tab for each request. Note: Synchronous AJAX requests can be identified as having a sysparm_processor value of AJAXGlideRecord. In the Post tab, record the sysparm_chars and sysparm_name values for each synchronous AJAX request. Note: If multiple requests have identical values for both parameters, then redundant requests for the same data are being issued and can be consolidated. From the Timeline column, record the combined timing for all synchronous AJAX requests with a sysparm_processor value of AJAXGlideRecord. Note: Converting these requests to async with the GlideAjax Application Programming Interface (API) can potentially reduce the time spent on the form load. To identify the client script that issues a synchronous AJAX call: Prepare a record link for the slow form.Click the JavaScript Debugger Window icon, which is the green bug located at the top right corner of the main frame.In the debugger window, click the Clear link.Click the link for the form.The JavaScript Debugger Window displays warning messages for each synchronous AJAX request. Note: These messages contain the following text: *** WARNING *** GlideRecord sync query for table: <table_name> The client script that issued the synchronous request is identified in a debug message immediately following the warning message. Note: These messages use the following format: onLoad <client_script_name> To resolve this issue by consolidating requests: Refactor and combine existing client scripts that make redundant requests for the same data.Make the call for the data at the top of a single script.In the newly combined client script, rewrite previously separate client scripts as functions that can be called after the data is retrieved. To resolve this issue by utilizing the GlideAjax API: The GlideAjax API allows for asynchronous calls for data and server-side script processing, which will not pause interaction with the form.In situations when it is okay for the user to begin interacting with the form prior to client script completion, GlideRecord and getReference() invocations can be replaced with GlideAjax equivalents. Note: For more information on using GlideAjax, refer to GlideAjax in the ServiceNow product documentation. Refactor eligible client scripts to use GlideAjax. If the issue continues to exist after following the steps in this article: Clearly identify the issue or question.Read the ServiceNow product documentation.Search the ServiceNow Community.Post a question on the ServiceNow Community forums. New users must create an account on the ServiceNow Community in order to post.Contact the Technical Support team.Additional InformationFor more information on related topics, review the following product documentation pages: Performance Troubleshooting GuidePerformance MetricsThread Performance MonitoringSystem Diagnostics For more topic-related issues, review the following Knowledge Base article: Troubleshooting slow performance