This tutorial is for:
By completing this tutorial, you will:
display: none causes widget layout issuesBefore starting this tutorial, ensure you have:
This tutorial applies to any widget that needs dynamic visibility control, particularly in carousels, tab interfaces, accordions, or responsive layouts.
When a widget is added to a page and hidden using display: none; in CSS, it creates layout issues:

There are two approaches depending on your layout requirements:
visibility: hidden to keep the widget's space in the layoutdisplay: none with resize events to reclaim spaceThis tutorial covers both approaches.
visibility PropertyUse this approach when you want the hidden widget to maintain its space in the layout, preventing other elements from shifting.
Add the widget container with visibility: hidden in the inline style.
<!-- Widget container with visibility control -->
<div id="widget" class="sr-widget" style="visibility: hidden"></div>Using visibility: hidden keeps the element in the DOM and maintains its layout space, unlike display: none.
Add the widget using standard initialization. The widget will render and measure correctly even though it's not visible.
<script>
(function(a,b,c,d,e,f,g,h,i){a[e]||(i=a[e]=function(){(a[e].q=a[e].q||[]).push(arguments)},i.l=1*new Date,i.o=f,
g=b.createElement(c),h=b.getElementsByTagName(c)[0],g.async=1,g.src=d,g.setAttribute("n",e),h.parentNode.insertBefore(g,h)
)})(window,document,"script", "https://widgets.sir.sportradar.com/sportradar/widgetloader", "SIR", {
language: "en"
});
SIR("addWidget", "#widget", "match.lmtPlus", {
matchId: 'your_match_id'
});
</script>Create a toggle function that switches between visible and hidden states.
const widget = document.getElementById('widget');
// Toggle widget visibility without affecting layout
const onWidgetToggle = () => {
widget.style.visibility = widget.style.visibility === 'hidden' ? 'visible' : 'hidden';
}The widget toggles visibility while maintaining its space in the layout:

When to use this approach:
display PropertyUse this approach when you want hidden widgets to collapse and allow other content to take their space.
Add the widget container with display: none in the inline style.
<!-- Widget container that collapses when hidden -->
<div id="widget" class="sr-widget" style="display: none;"></div>Widgets initialized while display: none may not render correctly. You must trigger a resize event when making them visible.
Add the widget using standard initialization.
<script>
(function(a,b,c,d,e,f,g,h,i){a[e]||(i=a[e]=function(){(a[e].q=a[e].q||[]).push(arguments)},i.l=1*new Date,i.o=f,
g=b.createElement(c),h=b.getElementsByTagName(c)[0],g.async=1,g.src=d,g.setAttribute("n",e),h.parentNode.insertBefore(g,h)
)})(window,document,"script", "https://widgets.sir.sportradar.com/sportradar/widgetloader", "SIR", {
language: "en"
});
SIR("addWidget", "#widget", "match.lmtPlus", {
matchId: 'your_match_id'
});
</script>Create a toggle function that changes display AND triggers a resize event.
const widget = document.getElementById('widget');
// Toggle widget display and trigger resize
const onWidgetToggle = () => {
// First change display property
widget.style.display = widget.style.display === 'none' ? 'block' : 'none';
// Then trigger resize event for layout recalculation
window.dispatchEvent(new Event('resize'));
}Critical: Always dispatch the resize event AFTER changing display. The widget needs this event to recalculate its responsive breakpoints and internal layout.
The widget toggles visibility while collapsing/expanding its space:

When to use this approach:
View Complete HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Widget Visibility - Preserve Space</title>
<style>
.carousel {
max-width: 800px;
margin: 0 auto;
}
.sr-widget {
border: 1px solid #ddd;
min-height: 400px;
}
.controls {
text-align: center;
margin: 20px;
}
</style>
</head>
<body>
<div class="carousel">
<div id="widget" class="sr-widget" style="visibility: hidden"></div>
<div class="controls">
<button onclick="onWidgetToggle()">Toggle Widget</button>
</div>
</div>
<script>
(function(a,b,c,d,e,f,g,h,i){a[e]||(i=a[e]=function(){(a[e].q=a[e].q||[]).push(arguments)},i.l=1*new Date,i.o=f,
g=b.createElement(c),h=b.getElementsByTagName(c)[0],g.async=1,g.src=d,g.setAttribute("n",e),h.parentNode.insertBefore(g,h)
)})(window,document,"script", "https://widgets.sir.sportradar.com/sportradar/widgetloader", "SIR", {
language: "en"
});
SIR("addWidget", "#widget", "match.lmtPlus", {
matchId: 'your_match_id'
});
const widget = document.getElementById('widget');
function onWidgetToggle() {
widget.style.visibility = widget.style.visibility === 'hidden' ? 'visible' : 'hidden';
}
</script>
</body>
</html>visibility for Fixed LayoutsChoose visibility: hidden when your layout requires consistent spacing and you don't want elements to shift when widgets appear/disappear.
display for Dynamic LayoutsChoose display: none when you want content to collapse and allow other elements to take the space, but always trigger resize events.
When showing widgets that were display: none, always call window.dispatchEvent(new Event('resize')) to ensure proper rendering.