Remove console.log function from html5 file

Hi all.
Using Hype 4, and have just delivered finished html5 ad’s (packages) to the controller in a media house in Norway (Schibsted). Now I get a message from the controller saying we have to remove any functions regarding console.log, because the media house requires this in further ad’s… Probably because they need the console to check the site, and don’t want to see the ad’s log in there. Hype is creating this function automaticly. Any chance to turn this function off? Or, wich portion of the html code can be removed manually?

Best regards, Morten Masch, Norway.

Hype doesn’t add any console.log functions automatically – if you’d like to share your document with us privately, you can share it with

1 Like

Thanks Daniel. Will do tomorrow.

1 Like

Hi, I have the same situation with Schibsted who is using AppNexus.
They will not accept the creatives unless this code is removed from index.html

" &&window.console.log(n)"

Any chance removing this could make the creatives not work properly?

The ads are created for Google Studio, pushed to Campaign manager, then imported as tags in AppNexus.

Apparently it's in the "hype_gereated_script.js"...

That's a good question. Personally, when I use try/catch, I often just put a double slash...

try {
      var x = 3 + 4;
} catch() {

Not having the "catch" part, after using try, will throw an error. Not having a "try" means the JavaScript could crash if something bad happens. So, that's why I usually just use the double slash. Who needs error reporting when you don't make any mistakes? :grinning_face_with_smiling_eyes:

Will removing it cause trouble? I'm not sure. I'm not sure why it's there in the first place. (I think console logging should be optional, dynamically added/removed with a setting in Hype. If it's not needed, it's just extra code and that's bad for advertisements — they need all the storage space they can get.)

The problem is that this is not the only place where console.log is used. I found three in HYPE-728.full.min.js

...and here's another fun one... window.console.log?... what's that about?!

Looks like I would have had trouble with that interview question too. HA HA! :smiley:

I suspect that this is part of the normal part of the hype runtime so it can spit out a console log of any errors it finds.

Pretty sure this is the lines that I would use to trace an error for example in a hype function syntax error
I would expect this to be part of the core functionality of the run time if I am correct.

The tumult tram would be able to tell you o e way or another.

@MarkHunte is correct; the purpose is primarily to log if there are user errors so that they can be discovered and corrected by users. (Secondarily there are some internal runtime failures that may log, but these are most likely also triggered from user errors).

I understand why an ad network would require removing console.log calls, although this does seem like a bit of an overreach when 3rd party framework libraries like Hype are involved.

Unfortunately I don't easily have the ability to test with AppNexus. For figuring out the right path with Hype, I'd be curious if you could let me know:

  • If you are presently using an export script or any advanced export options?
  • If you remove only the &&window.console.log(n) code from index.html (assuming you are inlining the hype_generated_script.js and there is just this single instance) does that solve the problem? Or does it later complain about it in the Hype runtime?
  • Instead of removing, if you change any instances of &&window.console.log(n) to exactly &&window["console"]["log"](n) does that pass without error?

Thank you!

Hi jonerikj

Here is the "solution" I ended up using for Schibstedt.
Some manual editing in the index.html file made the trick.
Hope this help you somewhat :slight_smile:

I think also I removed the window.console.log function from the index.html manually.
Been a while since I last made a banner for Schibsted, so it has slipped my mind somewhat :wink:

My previous comment is just for making the banner clickable...

1 Like