Slow Loading Page - Lots of New-UDElements

Hello Folks,

I made a page formating using a div table created using New-UDElement cmdlet and I was wondering if it could cause the slow loading of the page as I tested every functions and data gathering script and it those runs in approx 2-3 seconds and the page takes between 10-15 seconds to load.

Is there another way to acheive this ? New-UDRow and New-UDColumns are not really great for the page formating I’m aiming to do :frowning:

I’d love some thoughts about this.

Many thanks in advance !

Cheers

Edit : Code Example:

Blockquote

$DivCellCSSContent = @{
display = ‘table-cell’
border = ‘0x solid #999999
padding = ‘10px 10px’
‘vertical-align’ = ‘middle’
margin = ‘auto’
‘font-size’ = ‘12px’
}
$DivCellCSSLogo = @{
display = ‘table-cell’
border = ‘0px solid #999999
padding = ‘10px 10px’
‘vertical-align’ = ‘middle’
width = ‘10%’
margin = ‘auto’
color = ‘#A9A9A9
}

New-UDElement -Tag ‘div’ -Content {
# Row Group
New-UDElement -Tag ‘div’ -Content {
# Row 1
New-UDElement -Tag ‘div’ -Content {
# Cell
New-UDElement -Tag ‘div’ -Content {
New-UDElement -Tag ‘div’ -Content {
New-UDIcon -Icon desktop -Size 3x
}
} -Attributes @{
style = $DivCellCSSLogo
}
# Cell
New-UDElement -Tag ‘div’ -Content {

			New-UDElement -Tag 'div' -Content {
					"Last Machine Policy Refresh"
				} -Attributes @{
					style = @{
						'font-weight' = 'bold'
					}
				}
				
			New-UDElement -Tag 'div' -Content {
				$CMDevice.LastPolicyRequest
			}

		} -Attributes @{
			style = $DivCellCSSContent
		}
		# Cell
		New-UDElement -Tag 'div' -Content {

			New-UDElement -Tag 'div' -Content {
				New-UDIcon -Icon desktop -Size 3x
			}

		} -Attributes @{
			style = $DivCellCSSLogo
		}
		# Cell
		New-UDElement -Tag 'div' -Content {
			New-UDElement -Tag 'div' -Content {
				"Last Hardware Scan"
			} -Attribute @{
				style = @{
					'font-weight' = 'bold'
				}
			}

			New-UDElement -Tag 'div' -Content {
				$CMDevice.LastHardwareScan
			}

		} -Attributes @{
			style = $DivCellCSSContent
		}

	} -Attributes @{
		style = @{
			display = 'table-row'
		}
	}
	# Row 2
	New-UDElement -Tag 'div' -Content {
		New-UDElement -Tag 'div' -Content {
			New-UDElement -Tag 'div' -Content {
				New-UDIcon -Icon desktop -Size 3x
			} 
		} -Attributes @{
			style = $DivCellCSSLogo
		}

		New-UDElement -Tag 'div' -Content {
			
			New-UDElement -Tag 'div' -Content {
					"Last Software Scan"
				} -Attributes @{
					style = @{
						'font-weight' = 'bold'
					}
				}
				
				New-UDElement -Tag 'div' -Content {
					$CMDevice.LastSoftwareScan
				}

		} -Attributes @{
			style = $DivCellCSSContent
		}

		New-UDElement -Tag 'div' -Content {

			New-UDElement -Tag 'div' -Content {
				New-UDIcon -Icon desktop -Size 3x
			}

			
		} -Attributes @{
			style = $DivCellCSSLogo
		}

		New-UDElement -Tag 'div' -Content {
			New-UDElement -Tag 'div' -Content {
				"Client Version"
			} -Attribute @{
				style = @{
					'font-weight' = 'bold'
				}
			}
			
			New-UDElement -Tag 'div' -Content {
				$CMDevice.ClientVersion
			}

		} -Attributes @{
			style = $DivCellCSSContent
		}

	} -Attributes @{
		style = @{
			display = 'table-row'
		}
	}

	# Row 3
	New-UDElement -Tag 'div' -Content {
		New-UDElement -Tag 'div' -Content {
			New-UDElement -Tag 'div' -Content {
				New-UDIcon -Icon desktop -Size 3x
			} 
		} -Attributes @{
			style = $DivCellCSSLogo
		}

		New-UDElement -Tag 'div' -Content {
			
			New-UDElement -Tag 'div' -Content {
					"Resource ID"
				} -Attributes @{
					style = @{
						'font-weight' = 'bold'
					}
				}
				
				New-UDElement -Tag 'div' -Content {
					$CMDevice.ResourceID
				}

		} -Attributes @{
			style = $DivCellCSSContent
		}

		New-UDElement -Tag 'div' -Content {

			New-UDElement -Tag 'div' -Content {
				New-UDIcon -Icon desktop -Size 3x
			}

		} -Attributes @{
			style = $DivCellCSSLogo
		}

		New-UDElement -Tag 'div' -Content {
			New-UDElement -Tag 'div' -Content {
				"Logged On User"
			} -Attribute @{
				style = @{
					'font-weight' = 'bold'
				}
			}

				New-UDElement -Tag 'div' -Content {
				$CMDevice.CurrentLogonUser
				}
		} -Attributes @{
			style = $DivCellCSSContent
		}

	} -Attributes @{
		style = @{
			display = 'table-row'
		}
	}
} -Attributes @{
	style = @{
		display = 'table-row-group'
	}
}

} -Attributes @{
style = @{
display = ‘table’
width = ‘90%’
‘margin-left’ = ‘5%’
‘margin-right’ = ‘5%’
}
}

Evening @Speegel,

Why aren’t you using the built in html-table “New-UDTable” which formats a html-based table for you? Any styles you want added to said table should

Either way, i’m not seeing anything obvious that should slow it down, was expecting to see loads of endpoints.

Which UD version are you running?

Hello @BoSen29 !

Thanks for your quick reply ! I decided to restart the whole thing this morning + I added a load button on large data set in order to make it a bit faster and it now takes around 3 sec to load the whole thing which is rather normal.

I don’t really know what happened yesterday, it was probably a matter of cached variables.

I have another question though, is it possible to empty variables containing a large amount of data when a page / dynamic page is closed ? I think I may be helpful :smiley:

Hi @Speegel!

Sounds awesome, running on load shouldn’t differ performance wise from a load button though.

Depends on what kind of variables, non-fancy variables like $stuff inside endpoints will be cleared once the endpoint is cleared.

$cache variable will flush old variables on a interval in 2.7, and you can force it with Clear-UDCache
$session variable will clear after 25 minutes of idletime for the user.

Simplest of solutions to clear only the spesific $cache variable is doing “$cache:stuff = $null”

Happy hunting!

Hey @BoSen29,

I finally did the following in order to empty variable and clear all variables :

# Clean Cached Variables & Modules
    Remove-Variable * -ErrorAction SilentlyContinue
    foreach ($Module in $Modules) {
        Remove-Module -ErrorAction SilentlyContinue $Module
    }
    $error.Clear()
    Clear-Host

So far it works pretty well and do the trick.

Let me know if you have any comments or remarks, I’d be glad to hear what you think about it :slight_smile:

Cheers !

Hi @Speegel
If it works, it works :open_mouth:

I don’t see the need for “Clear-host” though? Do you run UD in commandline?