A teenager has been charged after paint was thrown at a mosque and a rock smashed a window while worshippers were inside.