@stkrog is right that the ui.R file is re-run only when the file changes.
Another way to make it re-run the code every time a new user session starts is to make the UI a function. You essentially just wrap your code in a function that returns the content, like this:
function(req) {
a <<- read.table("xxxx")
fluidPage(useShinyjs(),
tags$head(
includeCSS("styles.css"),
includeScript(path=ifelse(a==0,path1,path2))
)
)
}
The function will run each time someone connects, which will do what you want. Note that there is a performance cost to doing this, since it runs the UI code every time. In many cases, the performance cost is negligible, and it may be worth it in your case.