How to make widget load after page load

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2019 10:15 PM
We created a widget that queries quite a lot of data from incident table in one call and when we used that widget on a service portal page, the load time of that page is now very slow (it shows the default service portal Loading... page).
Is there any way we can defer the loading of the widget after the page loads - similar to how the Reports widget handles loading on service portal. Perhaps show a "Building widget..." prompt on the widget first on page load then once the page is loaded the actual widget query is run?
Better if we can output on browser console something like "Time to render widget: XXs" similar to the report widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 12:35 AM
I'm trying out this code, but getting a "Could not save record because of a compile error: JavaScript parse error at line (6) column (33) problem = syntax error" error and cannot save the Widget record. On the "c.server.update().then(() => {" line in the Client script. On Tokyo, pasting the script as is from above.
I'm trying to write a Widget that will scroll to a certain part of the page depending on URL parameters. I've got the scrolling working within a link but need it to run automatically when the page has finished loading.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
ServiceNow has introduced Defer Loading with Zurich release, you could leverage this and improve the user experience.
Another approach, simply return from server controller if not input and then set a time out on client controller and then invoke the server.update().