Make sure that Joomla namespace is defined otherwise define it!

This prevents error if core.js is not loaded by defining the Joomla namespace

Solves #5258