Add priority and parse JS options
Fix 'window is null' error