cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Avoid unload event listeners

avinean
Newcomer

The integration causes the issue which have an impact on site performance

 

`The unload event does not fire reliably and listening for it can prevent browser optimizations like the Back-Forward Cache. Use pagehide or visibilitychange events instead.`

https://gtmetrix.com/reports/www.timberland.com/badA1NJn/

3 REPLIES 3

natanael_mendes
Champion

The message you've provided indicates an issue related to the unload event in a web application being monitored by Dynatrace. Specifically, it mentions that the unload event does not reliably fire, and that listening for it can prevent browser optimizations like the Back-Forward Cache. To address this issue and potentially improve site performance, consider the following steps:

1. Review the Usage of the Unload Event:
- First, assess why you are using the unload event. Unload events are typically used to perform actions when a user navigates away from a web page, such as cleaning up resources or recording analytics data. Make sure you genuinely need this event for your specific use case.

2. Replace Unload Event with Pagehide Event:
- As recommended in the message, consider replacing the unload event with the pagehide event. The pagehide event is more reliable and can serve as an alternative for performing cleanup actions when a user leaves a page. Update your JavaScript code to use this event instead.

Example:
```javascript
window.addEventListener('pagehide', function(event) {
// Your cleanup or tracking code here
});
```

3. Test Impact on Site Performance:
- After making the code changes, thoroughly test your web application to ensure that the replacement of the unload event with the pagehide event does not negatively impact site performance or functionality. Monitor performance metrics to confirm that any optimizations you've made are effective.

4. Consider the Back-Forward Cache:
- Understand the implications of the Back-Forward Cache in modern browsers. The Back-Forward Cache aims to improve navigation speed by keeping a cached version of a page when users use the browser's back or forward buttons. Listening for certain events, like unload, can prevent the browser from utilizing this cache effectively.

5. Monitor with Dynatrace:
- Continue to use Dynatrace to monitor your web application's performance. Dynatrace can provide insights into how your changes impact performance and help you identify any new issues that may arise.

6. Optimize Other Aspects:
- While addressing this specific issue, also consider other optimizations for your website, such as reducing page load times, minimizing the use of synchronous JavaScript, and optimizing server-side processes. These optimizations can have a significant impact on site performance.

7. Stay Informed:
- Keep up-to-date with best practices for web performance and browser optimization. Web technologies and best practices evolve over time, so staying informed will help you make informed decisions for your web application.

By addressing the issue related to the unload event and optimizing your web application's performance, you can provide a better user experience while ensuring that Dynatrace monitoring continues to provide valuable insights.

Dynatrace Professional Certified

But as you can see in this report the issue points directly to ruxitagentjs file.

Doesn't it come from dynatrace?

avinean_0-1694607699021.png

 

paul_kapeller
Dynatrace Guide
Dynatrace Guide

Featured Posts