Suppress errors when nav does not exist on page #181

cherrmms opened this Issue Oct 9, 2015 · 1 comment


None yet

2 participants

cherrmms commented Oct 9, 2015

We are pulling in the responsive nav script globally for our site. However some pages do not contain a navigation element. Therefore errors are thrown due to the fact that the nav does not exist. How do I suppress the errors for pages that do not contain the nav?

Many Thanks!

Aybee commented Oct 9, 2015

Error is thrown by this line

I think this is not bad, or am I wrong?

You can suppress the init of your navigation by

if(document.getElementsByClassName('nav-collapse').length > 0) {
  var navigation = responsiveNav(".nav-collapse");

But then I think you also shouldn't load the responsive-nav.js to save resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment