You are correct that you can paste the JavaScript code without the script tags into your Modernizer file as long as you do it after the Modernizer object has been defined—that is, at the end of the Modernizer file.
The console.log
function does not log to a file on your server but to the JavaScript console in your web browser. Not all web browsers have a JavaScript console, but those that do you can view log messages and error messages there. Both Firefox and chrome have JavaScript consoles you can open. Remember console.log
should only be in your code for debugging.
One caveat is that some versions of Internet Explorer do not have console.log
defined when the JavaScript console is not open in the window.
This will cause your JavaScript to halt unexpectedly. Use Firefox or Chrome to examine how your code runs if you have a choice, it may save you a lot of time.
The alert
function is a less convenient way to debug. It will popup a dialog window in your browser with your message. You will need to dismiss the message to continue running the JavaScript program. Again, nothing will be logged serverside.