0 Replies Latest reply on Jun 30, 2017 6:58 PM by tim_234

    Typekit script fails as ES6 import

    tim_234

      Hi, I noticed that the kit scripts returned by Typekit do not use strict mode and they are thus invalid module imports and cannot be imported using the es6 import syntax. You can test this by opening a page with the following HTML in a browser that supports the script type=module such as the current version of Safari.

      <html>

        <body>

          <script type=module>

            import 'https://use.typekit.net/nnh8ewu.js';

          </script>

        </body>

      </html>

      You will see an error like:

      TypeError: undefined is not an object (evaluating 'this.g.document')

      That's because strict mode does not pass the global variable into the "this" variable of a function. The issue could easily be fixed by using "window" instead of "this".

       

      Perhaps it's finally time to re-evaluate the entire typekit loading system and give us a method that does not require  Javascript. Thanks muchly,

       

      Tim