protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

In browser, Uncaught ReferenceError: protobuf is not defined

Open taoxinyi opened this issue 6 years ago • 1 comments

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

taoxinyi avatar May 21 '18 14:05 taoxinyi