Html2canvas script doesn't load


#1

This is my project: https://glitch.com/edit/#!/twit-original

I have the html2canvas script loaded in my index.html but when I try to use it in my javascript it gives a ‘html2canvas’ is not defined error


#2

It looks like the Promised-based feature is from html2canvas v1 but the glitch has html2canvas v0.4.1 loaded. The docs for v0.4.1 look like they are here: https://github.com/niklasvh/html2canvas/tree/0.4.1

Alternatively you can use the newer one from here: https://unpkg.com/html2canvas@1.0.0-alpha.9/dist/html2canvas.js


#3

Oh @rajsite forgot to mention, html2canvas above v1 doesn’t load. Tried it already. If I drop it in the project it just shows an empty file.


#4

There are copy/paste size restrictions and limits on the size of file that are shown in the editor (https://glitch.com/faq#restrictions). If it’s a library file, I suggest referencing it directly or uploading the file to assets and referencing it from there.


#5

Added it to the assets folder and linked to it in index.html, still getting ‘html2canvas’ is not defined. (this is the 1.0.0-alpha.9 version)


#6

It’s just warning from the linter, the code will still work if it’s valid. You can add /* global html2canvas */ to the top of the file to make the warning go away.


#7

Ah ok, got it working. thank you!!