Fixed issue with other js scripts not running

Issues fixed. No tests needed. Issue was caused by trying to get an attribute of an element without checking if that element exists.