In a website I'm working on, a javascript file (and a css too) gets downloaded even if the feature it's related with is not present on the page. Since that plugin doesn't allow to load the files only when needed, I wanted to use a wordpress hook to dequeue them when not necessary.
To know if this scripts are needed, I could check inside the html code if a specific element is present (using regex or another method), but I don't know which hook to use and how to get the html data. Could anyone show me how to do it or even just point me to some documentation about it?