DEV Community

shruti jain
shruti jain

Posted on

Self-Updating Widgets (No Manual Changes!)

πŸ’‘ Problem: What if you release an update, but users have already embedded an old version?

βœ… Solution: Use a versioning system in your script URL:

<script src="https://cdn.yourdomain.com/widget.js?v=2.0.1"></script>
Enter fullscreen mode Exit fullscreen mode

Or, force fresh loads by appending a timestamp:

<script src="https://cdn.yourdomain.com/widget.js?t=" + Date.now()></script>
Enter fullscreen mode Exit fullscreen mode

This ensures no cache issues and always loads the latest version.

Top comments (0)