-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent or intercept AMP Optimizer warning in console #1263
Comments
+1, I've ran into this before as well. Given how expected this message is, we should a way of disabling it. Some ideas:
|
The |
few things
|
Please let me know if I'm misunderstanding: Let's say I'm building a page with 10 images and I know for certain only the top 4 would ever be in the first viewport. |
Agree. Since the errors come from AMP Optimizer is causing unnecessary logs in production, which is very costly.
|
Just to be clear, regarding the warning, yes the fix is to increase the |
yes, I don't think thats an issue and wouldn't create any warning. |
|
Wherever you are providing your const ampOptimizer = AmpOptimizer.create({
extensionVersions: {
'amp-twitter': '0.1',
},
}); you can add a const ampOptimizer = AmpOptimizer.create({
extensionVersions: {
'amp-twitter': '0.1',
},
log: {
info: () => {},
warn: () => {},
debug: () => {},
error: () => {},
}
}); You could do this more cleanly by building off of the existing one const myLog = require('@ampproject/toolbox-core/lib/Log.js');
myLog.output_.originalWarn = myLog.output_.warn
myLog.output_.warn = (() => { process.env.I_AM_IN_PRODUCTION_AND_KNOW_THIS_BECUASE_OF_AN_ENV_VAR ? () => {} : myLog.output_.originalWarn})()
const ampOptimizer = AmpOptimizer.create({
extensionVersions: {
'amp-twitter': '0.1',
},
log: myLog
});
does that make sense? |
Wow nice, I will try this. Thanks @patrickkettner for the detailed solution. |
@sebastianbenz would it make sense to create a |
Thanks for the workaround @patrickkettner (I just wanted to write the same)! Loglevels would be the best solution, but in this case it'd probably make more sense to print this message only in debug mode. |
Hi, is there any way to prevent or intercept
AMP Optimizer
warning on console?Thanks
The text was updated successfully, but these errors were encountered: