Add WeakRef API for scripts managing external resources