Custom javascript gets only applied after refresh, creating categories for location plugin

No, using the plugin api in script tags (in the header) is deprecated.