nkashyap / console.io

JavaScript Remote Web Console
http://nkashyap.github.io/console.io
189 stars 20 forks source link

console.log before DOMContentLoad not shown in console panel #40

Closed modten closed 1 year ago

modten commented 8 years ago
<script type="text/javascript" src="http://localhost:8082/console.io.js"></script>
<script>
// not work
console.log(123456)
$(function() {
    // this works
    console.log(456789)
})
</script>

EventEmitter.prototype.emit = function (name) {
    if (!this.$events) {

        // Just return will lose events. using setTimeout or queue to ensure the event truly emitted
        var _this = this;
        var _arguments = arguments;
        setTimeout(function() {
            EventEmitter.prototype.emit.apply(_this, [].slice.call(_arguments));
        }, 10);

        return false;
    }
}
nkashyap commented 8 years ago

Yes, current implementation of console.io works after DOMContentLoad event if fired. It was designed to work with requirejs.