protobuf.js
protobuf.js copied to clipboard
In browser, Uncaught ReferenceError: protobuf is not defined
protobuf.js version: <6.8.6>
I used protobuf.min.js. But protobuf.load is only available in callback function. Otherwise 'Uncaught ReferenceError: protobuf is not defined at xxxx' will show.
For example, the following is not working. So how to avoid this error and load the model once and for all instead of loading it for multiple times in callback function.
<script src="{% static "js/protobuf.min.js" %}"></script>
<script>
protobuf.load("{% static "notification_message.proto" %}", function (err, root) {
if (err)
throw err;
var notificationItem = root.lookupType("chat.NotificationItem");
</script>
Error
Uncaught ReferenceError: protobuf is not defined at xxxx