0

I am using codekit to put together a few things.

  1. jQuery
  2. Modernizr (prepended to the script below)

So I'm just troubleshooting some things and getting back to basics on a project. As is, jsHint returns the error

if (Modernizr.touch) {

'Modernizr' is not defined. 

and so then I add in:

/*global Modernizr:true */

but then, I get -

Modernizr' was used before it was defined.

(function($){

// =========================================

  $(document).ready(function() {
  // ===============================


    if (Modernizr.touch) {

      alert('touch');

    } else {

      //alert('no-touch');

    }

  // ===============================
  });

// =========================================
})(jQuery);

The alert works, and it's adding the class to my < html > etc... but this is driving me mad.

What am I doing wrong? (besides using codekit instead of brunch)

morten.c
  • 3,414
  • 5
  • 40
  • 45
sheriffderek
  • 8,848
  • 6
  • 43
  • 70
  • weird. when i try the same with jslint, i don't get any complaints about modernizer. – Kevin B Apr 08 '14 at 19:12
  • also, when i input your code + the comment here: http://www.jshint.com/ it doesn't give me any warnings. – Kevin B Apr 08 '14 at 19:14
  • It could be this new codekit 2. I have a feeling it is doing crazy stuff because this project is giving me tons of trouble on every front. – sheriffderek Apr 08 '14 at 19:20

1 Answers1

0

The easiest way to check whether the issue with JSHint itself or your configuration/editor is to paste your code on jshint.com. With your code, I assume you're either not providing the full listing or your editor does something weird. Because 'Modernizr' was used before it was defined. appears only when latedef option is turned on and you're accessing your variable before its declaration.

Anton Kovalyov
  • 2,808
  • 1
  • 22
  • 11